*-------------------------------------------------------------------------------------------------------------------------------------------*

// Replication code for "Correcting Citizens’ Misperceptions about non-Western Immigrants: Corrective Information, Interpretations, and Policy Opinions"
// Authors: Frederik Jørgensen, Mathias Osmundsen
// Publication: Journal of Experimental Political Science

*-------------------------------------------------------------------------------------------------------------------------------------------*



log using correcting_misperception_recoded, name(correcting_misperception_recoded) text replace

use"correcting_misperception.dta",clear

********************
**Recode Variables**
********************
*Information treatments* 
*crime treatment
gen crime_treatment = .
replace crime_treatment = 0 if treatment == .
replace crime_treatment = 1 if treatment != .
*welfare treatment
gen welfare_treatment = .
replace welfare_treatment = 0 if q163 == .
replace welfare_treatment = 1 if q163 != .
*number treatment
gen number_treatment = .
replace number_treatment = 0 if q130 == .
replace number_treatment = 1 if q130 != .


*Prior beliefs. Calculate prior beliefs on crime, welfare and size. 
*NOTE: also calculate for Danes and Western immigrant
*crime priors non-western immigrants collapsed across conditions 
egen crimeprior = rmean(crime1iv_1 crimeciv_1 num_crimeiv_1 off_crimeiv_1)
*welfare priors non-western immigrants collapsed across conditions 
egen welfareprior = rmean(welfare1iv_1 welfareciv_1 num_offiv_1 off_offiv_1)
*number priors non-western immigrants collapsed across conditions 
egen numberprior = rmean(num1iv_1 numciv_1 num_numiv_1 off_numiv_1)


*Outcome variables*

*posterior beliefs. NOTE: also calculate for Danes and Western immigrant
*crime posterior non-western immigrants collapsed across conditions 
egen crimeposterior = rmean(post1iv_1 postciv_1 num_crimepostiv_1 off_postcrimeiv_1)
*welfare posterior non-western immigrants collapsed across conditions
egen welfareposterior = rmean(postoffiv_1 postoffiv_c_1 num_offpostiv_1 off_postoffiv_1 )
*number posterior non-western immigrants collapsed across conditions
egen numberposterior = rmean(postnumiv_1 postnumiv_c_1 num_numpostiv_1 off_postoffiv_1_0)


*Interpretation measures. (interpretations of immigration information)
*interpretation of crime
egen crimeinterpretation = rmean(dv_interpretationcri interpretationcrim_c treat_num_crime_int treat_off_int_crime)
*interpretation of welfare
egen welfareinterpretation = rmean(dv_interpretationoff interpretationoff_c treat_num_off_int treat_off_int_off)
*interpretation of size of the migrant population
egen numberinterpretation = rmean(dv_interpretationnum interpretationnum_c treat_num_num_int treat_off_int_num)


*Measures of policy preferences* 
*collapse policy items across treatment conditions
forvalues i = 1/3 {
  egen policyA_`i' = rmean(dv_policy1_`i' dv_policy1c_`i' num_dvpolicy1_`i' off_policy1_`i')
  egen policyB_`i' = rmean(dv_policy2_`i' dv_policy2_c_`i' num_dvpolicy2_`i' off_policy2_`i')
 } 
*overall measure of policy preferences
alpha policyA_2 policyB_3 policyA_1 policyB_1 policyA_3 policyB_2, gen(antiim_policy)
//scale reliability = 0.85

*Scaling variables (min=0, max=1)
foreach var in crimeprior welfareprior numberprior crimeposterior welfareposterior numberposterior crimeinterpretation welfareinterpretation numberinterpretation antiim_policy {
su `var', meanonly 
gen `var'_01 = (`var' - r(min))/(r(max) - r(min))
}
*



*Center priors and posteriors on the true value by subtracting the true value
g c_crimeprior = crimeprior_01-0.21
g c_welfareprior=welfareprior_01-0.14
g c_numberprior=numberprior_01-0.08

g c_welfarepost=welfareposterior_01-0.14
g c_crimepost=crimeposterior_01-0.21
g c_numpost=numberposterior_01-0.08

save"correcting_misperception_recoded.dta",replace



********************************************************************************
***************************Results in the Manuscript****************************
********************************************************************************
use "correcting_misperception_recoded.dta",clear //use data set with recoded variables

**Figure 1**
//Here we plot the the posterior of the treatment group against the posterior of 
//the control for each information treatment respectively
//setting eth1==1 means that we only include natives

*Top left panel. Welfare experiment
gr twoway (kdensity welfareposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==0 ///
& crime_treatment==0, kernel(gaussian) lcolor(black) lpattern(solid)) ///
kdensity welfareposterior if eth1 == 1 & welfare_treatment==1 & number_treatment==0 ///
& crime_treatment==0, kernel(gaussian) lcolor(black) lpattern(dash)  ///
legend(order(1 "Control posterior" 2 "Treatment posterior") ///
 position(1) row(4) ring(0) size(vsmall) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
xlabel(,valuelabels angle(0) labsize(small)) ///
yscale(r(0(0.01).04)) ylabel(0(0.01)0.04) ///
ylabel(,valuelabels labsize(small) nogrid) ///
xline(14, lcolor(black) lpattern(shortdash)) ///
xtitle("") ///
ytitle("Density", size(small)) ///
graphregion(margin(small) color(white)) plotregion(lcolor(black)) ///
title("Welfare Experiment",size(medium) color(black) ///
box bexpand bcolor(gs14) lcolor(black)) name(welf_exp,replace)
*Top right panel. Crime experiment
gr twoway (kdensity crimeposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==0 ///
& crime_treatment==0, kernel(gaussian) lcolor(black) lpattern(solid)) ///
kdensity crimeposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==0 ///
& crime_treatment==1, kernel(gaussian) lcolor(black) lpattern(dash)  ///
legend(order(1 "Control posterior" 2 "Treatment posterior") ///
 position(1) row(4) ring(0) size(vsmall) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
xlabel(,valuelabels angle(0) labsize(small)) ///
yscale(r(0(0.01).04)) ylabel(0(0.01)0.04) ///
ylabel(,valuelabels labsize(small) nogrid) ///
xline(21, lcolor(black) lpattern(shortdash)) ///
xtitle("") ///
ytitle("Density", size(small)) ///
graphregion(margin(small) color(white)) plotregion(lcolor(black)) ///
title("Crime Experiment",size(medium) color(black) ///
box bexpand bcolor(gs14) lcolor(black)) name(crime_exp,replace)
*Bottom panel. Size experiment
gr twoway (kdensity numberposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==0 ///
& crime_treatment==0, kernel(gaussian) lcolor(black) lpattern(solid)) ///
kdensity numberposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==1 ///
& crime_treatment==0, kernel(gaussian) lcolor(black) lpattern(dash)  ///
legend(order(1 "Control posterior" 2 "Treatment posterior") ///
 position(1) row(4) ring(0) size(vsmall) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
xlabel(,valuelabels angle(0) labsize(small)) ///
yscale(r(0(0.01).04)) ylabel(0(0.01)0.04) ///
ylabel(,valuelabels labsize(small) nogrid) ///
xline(9, lcolor(black) lpattern(shortdash)) ///
xtitle("") ///
ytitle("Density", size(small)) ///
graphregion(margin(small) color(white)) plotregion(lcolor(black)) ///
title("Size Experiment",size(medium) color(black) ///
box bexpand bcolor(gs14) lcolor(black)) name(num_exp,replace)

*Combine the 3 panel into one plot. Figure 1:
graph combine welf_exp crime_exp num_exp ///
, row(2) graphregion(margin(tiny) color(white)) plotregion(margin(zero) color(white))

**Figure 2**
//Here we regress the posterior expectation on the respective information treatment
//while also splitting the sample according to prior expectations.
//Specifically, we categorize participants into four groups: 
//(1) underestimators: those who reported prior expectation below the true value
//(2) small overestimators: those who were about right (participants in the 33.33 
//percentile among those above the true value)
//(3) moderate overestimators: (participants between the 33.33 and 66.67 percentile)
//(4) large overestimators: (participants above the 66.67 percentile)

*generate categories of prior expectations
*welfare
g welf_cat=.
replace welf_cat=0 if c_welfareprior<0
_pctile c_welfareprior if eth1==1 & c_welfareprior>=0 & crime_treatment==0 & number_treatment==0, p(33.33, 66.67)
replace welf_cat=1 if c_welfareprior>=0 & c_welfareprior<=r(r1)
replace welf_cat=2 if c_welfareprior>r(r1) & c_welfareprior<r(r2)
replace welf_cat=3 if c_welfareprior>=r(r2)
*crime
g crime_cat=.
replace crime_cat=0 if c_crimeprior<0
_pctile c_crimeprior if eth1==1 & c_crimeprior>=0 & welfare_treatment==0 & number_treatment==0, p(33.33, 66.67)
replace crime_cat=1 if c_crimeprior>=0 & c_crimeprior<=r(r1)
replace crime_cat=2 if c_crimeprior>r(r1) & c_crimeprior<=r(r2)
replace crime_cat=3 if c_crimeprior>r(r2)
*size
g num_cat=.
replace num_cat=0 if c_numberprior<0
_pctile c_numberprior if eth1==1 & c_numberprior>=0 & welfare_treatment==0 & crime_treatment==0, p(33.33, 66.67)
replace num_cat=1 if c_numberprior>=0 & c_numberprior<=r(r1)
replace num_cat=2 if c_numberprior>r(r1) & c_numberprior<r(r2)
replace num_cat=3 if c_numberprior>=r(r2)


*save data set to keep the prior expextation categories*
save"correcting_misperception_recoded.dta",replace



*Top left panel of Figure 2
*average effect of treatment across the categories of the prior
reg c_welfarepost welfare_treatment   if eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto overall
*effect among underestimators
reg c_welfarepost welfare_treatment c_welfareprior if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto underestimators
*effect among small overestimators
reg c_welfarepost welfare_treatment  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto small
*effect among moderate overestimators
reg c_welfarepost welfare_treatment  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto moderate
*effect among large overestimators
reg c_welfarepost welfare_treatment  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto large
*Plotting the coefs. from above. Top left panel of Figure 2: 
coefplot (overall, mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(underestimators,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(small,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(moderate,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(large,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
,aseq swapnames nooffset grid(no) legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
legend(off) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-.2(.1).1)) xlabel(-.2(.1).1) ///
yscale(alt axis(2)) ///
groups(overall = "N = 797" ///
underestimators = "N = 54" ///
small = "N = 248" ///
moderate = "N = 220" large = "N = 275", nogap angle(horizontal))  ///
coeflabels(overall = "Overall" underestimators = "Underestimators" ///
small = "Small overestimators" moderate = "Moderate overestimators" large = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Welfare experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(welfare_exp,replace)


*Top right panel of Figure 2
*Average effect across across prior expectations
reg c_crimepost crime_treatment  if eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto overall_c
*effect among underestimators
reg c_crimepost crime_treatment  if crime_cat==0 & eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto underestimators_c
*effect among small overestimators
reg c_crimepost crime_treatment  if crime_cat==1 & eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto small_c
*effect among moderate overestimators 
reg c_crimepost crime_treatment  if crime_cat==2 & eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto moderate_c
*effect among large overestimators
reg c_crimepost crime_treatment  if crime_cat==3 & eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto large_c
*plotting the above coefs. top right panel of Figure 2:
coefplot (overall_c, mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(underestimators_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(small_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(moderate_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(large_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
,aseq swapnames nooffset grid(no) legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
legend(off) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-.2(.1).1)) xlabel(-.2(.1).1) ///
yscale(alt axis(2)) ///
groups(overall_c = "N = 814" ///
underestimators_c = "N = 168" ///
small_c = "N = 217" ///
moderate_c = "N = 216" large_c = "N = 213", nogap angle(horizontal))  ///
coeflabels(overall_c = "Overall" underestimators_c = "Underestimators" ///
small_c = "Small overestimators" moderate_c = "Moderate overestimators" large_c = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Crime experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(crime_exp,replace)


*Bottom panel of Figure 2.
*Average effect across prior expectations
reg c_numpost number_treatment  if eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto overall_n
*effect among underestimators
reg c_numpost number_treatment   if num_cat==0 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto underestimators_n
*effect among small overestimators
reg c_numpost number_treatment  if num_cat==1 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto small_n
*effect among moderate overestimators
reg c_numpost number_treatment  if num_cat==2 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto moderate_n
*effect among large overestimators
reg c_numpost number_treatment   if num_cat==3 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto large_n
*plotting the above coefs to get the bottom panel of Figure 2:
coefplot (overall_n, mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(underestimators_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(small_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(moderate_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(large_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
,aseq swapnames nooffset grid(no) legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
legend(off) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-.2(.1).1)) xlabel(-.2(.1).1) ///
yscale(alt axis(2)) ///
groups(overall_n = "N = 819" ///
underestimators_n = "N = 143" ///
small_n = "N = 232" ///
moderate_n = "N = 214" large_n = "N = 230", nogap angle(horizontal))  ///
coeflabels(overall_n = "Overall" underestimators_n = "Underestimators" ///
small_n = "Small overestimators" moderate_n = "Moderate overestimators" large_n = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Size experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(num_exp,replace)


*Combine all three panels into one plot. Figure 2:
graph combine welfare_exp crime_exp num_exp ///
,  row(2)  imargin(0 0 0 0) graphregion(margin(tiny) color(white)) plotregion(margin(zero))


**Figure 3**
//We repeat the above analyses but change the outcome to policy preferences

*Top left panel of Figure 3. Welfare experiment
*average effect across prior expectations
reg antiim_policy_01 welfare_treatment   if eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto overall
*effect among underestimators
reg antiim_policy_01 welfare_treatment  if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto underestimators
*effect among small overestimators
reg antiim_policy_01 welfare_treatment  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto small
*effect among moderate overestimators
reg antiim_policy_01 welfare_treatment  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto moderate
*effect among large overestimators
reg antiim_policy_01 welfare_treatment  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto large
*plot the above coefs
coefplot (overall, mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(underestimators,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(small,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(moderate,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(large,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
,aseq swapnames nooffset grid(no) legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
legend(off) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-.2(.1).1)) xlabel(-.2(.1).1) ///
yscale(alt axis(2)) ///
groups(overall = "N = 797" ///
underestimators = "N = 54" ///
small = "N = 248" ///
moderate = "N = 220" large = "N = 275", nogap angle(horizontal))  ///
coeflabels(overall = "Overall" underestimators = "Underestimators" ///
small = "Small overestimators" moderate = "Moderate overestimators" large = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Welfare experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(welfare_exp,replace)

*Top righ panel of Figure 3. Crime experiment 
*Average effect
reg antiim_policy_01 crime_treatment  if eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=.,r
est sto overall_c
*Effect among underestimators
reg antiim_policy_01 crime_treatment  if crime_cat==0 & eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=.,r
est sto underestimators_c
*Effect among small overestimators
reg antiim_policy_01 crime_treatment  if crime_cat==1 & eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=.,r
est sto small_c
*Effect among moderate overestimators
reg antiim_policy_01 crime_treatment  if crime_cat==2 & eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=.,r
est sto moderate_c
*Effect among large overestimators
reg antiim_policy_01 crime_treatment  if crime_cat==3 & eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=. ,r
est sto large_c
*plot the above coefs
coefplot (overall_c, mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(underestimators_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(small_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(moderate_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(large_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
,aseq swapnames nooffset grid(no) legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
legend(off) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-.2(.1).1)) xlabel(-.2(.1).1) ///
yscale(alt axis(2)) ///
groups(overall_c = "N = 814" ///
underestimators_c = "N = 168" ///
small_c = "N = 217" ///
moderate_c = "N = 216" large_c = "N = 213", nogap angle(horizontal))  ///
coeflabels(overall_c = "Overall" underestimators_c = "Underestimators" ///
small_c = "Small overestimators" moderate_c = "Moderate overestimators" large_c = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Crime experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(crime_exp,replace)

*Bottom panel of Figure 3. Size experiment
*Average effect
reg antiim_policy_01 number_treatment  if eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto overall_n
*Effect among underestimators´
reg antiim_policy_01 number_treatment   if num_cat==0 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto underestimators_n
*Effect among small overestimators
reg antiim_policy_01 number_treatment  if num_cat==1 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto small_n
*Effect among moderate overestimators
reg antiim_policy_01 number_treatment  if num_cat==2 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto moderate_n
*Effect among large overestimators
reg antiim_policy_01 number_treatment   if num_cat==3 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto large_n
*Plot the above coefs.
coefplot (overall_n, mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(underestimators_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(small_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(moderate_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(large_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
,aseq swapnames nooffset grid(no) legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
legend(off) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-.2(.1).1)) xlabel(-.2(.1).1) ///
yscale(alt axis(2)) ///
groups(overall_n = "N = 819" ///
underestimators_n = "N = 143" ///
small_n = "N = 232" ///
moderate_n = "N = 214" large_n = "N = 230", nogap angle(horizontal))  ///
coeflabels(overall_n = "Overall" underestimators_n = "Underestimators" ///
small_n = "Small overestimators" moderate_n = "Moderate overestimators" large_n = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Size experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(num_exp,replace)

*Combine all three panels into one plot. Figure 3:
graph combine welfare_exp crime_exp num_exp ///
,  row(2)  imargin(0 0 0 0) graphregion(margin(tiny) color(white)) plotregion(margin(zero))


**Figure 4**
//We repeat the above analyses but use the interpretation measures as outcomes

*Top left panel of Figure 4. Welfare experiment 
*Average effect across prior expectation categories
reg welfareinterpretation_01 welfare_treatment   if eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto overall
*Effect among underestimators 
reg welfareinterpretation_01 welfare_treatment  if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto underestimators
*Effect among small overestimators
reg welfareinterpretation_01 welfare_treatment  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto small
*Effect among moderate overestimators
reg welfareinterpretation_01 welfare_treatment  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto moderate
*Effect among large overestimators
reg welfareinterpretation_01 welfare_treatment  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto large
*Plot above coefs. Top left panel of Figure 4:
coefplot (overall, mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(underestimators,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(small,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(moderate,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
(large,mcolor(black) keep(welfare_treatment) levels(95) ciopts(color(black))) ///
,aseq swapnames nooffset grid(no) legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
legend(off) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-.1(.1).2)) xlabel(-.1(.1).3) ///
yscale(alt axis(2)) ///
groups(overall = "N = 797" ///
underestimators = "N = 54" ///
small = "N = 248" ///
moderate = "N = 220" large = "N = 275", nogap angle(horizontal))  ///
coeflabels(overall = "Overall" underestimators = "Underestimators" ///
small = "Small overestimators" moderate = "Moderate overestimators" large = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Welfare experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(welfare_exp,replace)

*Top right panel of Figure 4. Crime experiment
*Average effect
reg crimeinterpretation_01 crime_treatment  if eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=.,r
est sto overall_c
*Effect among underestimators 
reg crimeinterpretation_01 crime_treatment  if crime_cat==0 & eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=.,r
est sto underestimators_c
*Effect among small overestimators
reg crimeinterpretation_01 crime_treatment  if crime_cat==1 & eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=.,r
est sto small_c
*Effect among moderate overestimators
reg crimeinterpretation_01 crime_treatment  if crime_cat==2 & eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=.,r
est sto moderate_c
*Effect among small overestimators
reg crimeinterpretation_01 crime_treatment  if crime_cat==3 & eth1 == 1 & welfare_treatment==0 & number_treatment==0 & c_crimepost!=. ,r
est sto large_c
*plot the above coefs. Top right panel of Figure 4:
coefplot (overall_c, mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(underestimators_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(small_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(moderate_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
(large_c,mcolor(black) keep(crime_treatment) levels(95) ciopts(color(black))) ///
,aseq swapnames nooffset grid(no) legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
legend(off) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-.1(.1).2)) xlabel(-.1(.1).3) ///
yscale(alt axis(2)) ///
groups(overall_c = "N = 814" ///
underestimators_c = "N = 168" ///
small_c = "N = 217" ///
moderate_c = "N = 216" large_c = "N = 213", nogap angle(horizontal))  ///
coeflabels(overall_c = "Overall" underestimators_c = "Underestimators" ///
small_c = "Small overestimators" moderate_c = "Moderate overestimators" large_c = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Crime experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(crime_exp,replace)

*Bottom panel of Figure 4. Size experiment:
*Average effect
reg numberinterpretation_01 number_treatment  if eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto overall_n
*Effect among underestimators
reg numberinterpretation_01 number_treatment   if num_cat==0 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto underestimators_n
*Effect among small overestimators
reg numberinterpretation_01 number_treatment  if num_cat==1 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto small_n
*Effect among moderate overestimators
reg numberinterpretation_01 number_treatment  if num_cat==2 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto moderate_n
*Effect among large overestimators
reg numberinterpretation_01 number_treatment   if num_cat==3 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto large_n
*Plot above coefs. Bottom panel of Figure 4:
coefplot (overall_n, mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(underestimators_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(small_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(moderate_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
(large_n,mcolor(black) keep(number_treatment) levels(95) ciopts(color(black))) ///
,aseq swapnames nooffset grid(no) legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
legend(off) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-.1(.1).2)) xlabel(-.1(.1).3) ///
yscale(alt axis(2)) ///
groups(overall_n = "N = 819" ///
underestimators_n = "N = 143" ///
small_n = "N = 232" ///
moderate_n = "N = 214" large_n = "N = 230", nogap angle(horizontal))  ///
coeflabels(overall_n = "Overall" underestimators_n = "Underestimators" ///
small_n = "Small overestimators" moderate_n = "Moderate overestimators" large_n = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Size experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(num_exp,replace)

*Combine all three panels into one plot. Figure 4:
graph combine welfare_exp crime_exp num_exp ///
,  row(2)  imargin(0 0 0 0) graphregion(margin(tiny) color(white)) plotregion(margin(zero))


********************************************************************************
*********************Results in the Supplementary Material**********************
********************************************************************************

***********************************
*Appendix B.1. Sample Characterics* 
***********************************
*Pre measured independent variables*
*ideology - recode to 0-1, high values = right-wing
egen ideomin = min(ideology)
egen ideomax = max(ideology)
gen ideology_01 = (ideology - ideomin) / (ideomax - ideomin)
drop ideomin ideomax 
label var ideology_01 "Ideological Self-Placement (from left-right) - 0 to 1"

*eco ideology - recode to 0-1, high values = right-wing
egen ideomin = min(a_ko_pol)
egen ideomax = max(a_ko_pol)
gen eco_ideology_01 = (a_ko_pol - ideomin) / (ideomax - ideomin)
drop ideomin ideomax 
label var eco_ideology_01 "Ideological Eco Self-Placement (from left-right) - 0 to 1"

*soc ideology - recode to 0-1, high values = right-wing
egen ideomin = min(ny_pol)
egen ideomax = max(ny_pol)
gen soc_ideology_01 = (ny_pol - ideomin) / (ideomax - ideomin)
drop ideomin ideomax 
label var soc_ideology_01 "Ideological Soc Self-Placement (from left-right) - 0 to 1"

*income
egen Income = rmean(income incomec q128 q161)
recode Income (10=.) 

*education
egen Education = rmean(education educationc q129 q162)
recode Education (7=.) 

*Age
sum age if eth1 == 1 // m=30, sd=15
*female 
sum gender if eth1 == 1 // m=50 % , sd=.5
*education < high school
tab Education if eth1 == 1
*Income 
sum Income, detail

**************************************************
*Appendix B.2.* Prior and Posterior Distributions*
**************************************************

*Figure B.1.
//Each distribution displays the respective prior or posterior, where we have
//summed the questions concerning non-Western immigrants, Western immigrants, 
//and Danes

*First we generate the new variables:
*crime priors western immigrants collapsed across conditions
egen crimeprior_western = rmean(crime1v_1 crimecv_1 num_crimev_1 off_crimev_1)
*crime priors danes collapsed across conditions
egen crimeprior_danes = rmean(crime1dk_1 crimecdk_1 num_crimedk_1 off_crimedk_1)

*welfare priors western immigrants collapsed across conditions
egen welfareprior_western = rmean(welfare1v_1 welfarecv_1 num_offv_1 off_offv_1)
*welfare priors danes collapsed across conditions
egen welfareprior_danes = rmean(welfare1dk_1 welfarecdk_1 num_offdk_1 off_offdk_1 )

*size priors western immigrants collapsed across conditions
egen sizeprior_western = rmean(num1v_1 numcv_1 num_numv_1 off_numv_1)
*size priors danes immigrants collapsed across conditions
egen sizeprior_danes = rmean(num1dk_1 numcdk_1 num_numdk_1 off_numdk_1)

*crime posteriors western immigrants collapsed across conditions
egen crimepost_western = rmean(post1v_1 postcv_1 num_crimepostv_1 off_postcrimev_1)
*crime posteriors danes collapsed across conditions
egen crimepost_danes = rmean(post1dk_1 postcdk_1 num_crimepostv_1 off_postcrimedk_1)

*welfare posteriors western immigrants collapsed across conditions
egen welfarepost_western = rmean(postoffv_1 postoffv_c_1 num_offpostv_1 off_postoffv_1)
*welfare posteriors danes collapsed across conditions
egen welfarepost_danes = rmean(postoffdk_1 postoffdk_c_1 num_offpostdk_1 off_postoffdk_1)

*size posteriors western immigrants collapsed across conditions
egen sizepost_western = rmean(postnumv_1 postnumv_c_1 num_numpostv_1 off_postoffv_1_0)
*size posteriors danes immigrants collapsed across conditions
egen sizepost_danes = rmean(postnumdk_1 postnumdk_c_1 num_numpostdk_1 off_postnumdk_1)


*Then we add the priors together and plot the disributions to see if the prior sum to 100 
*Do crime priors sum to 100?
gen sum_crime_prior = crimeprior_western + crimeprior_danes + crimeprior

hist sum_crime_prior, color(gs12) lcolor(black) ///
graphregion(color(white) margin(tiny)) plotregion(fcolor(white) lcolor(black)) ///
bgcolor(white) ylabel(, nogrid) yscale(r(0(.2).06)) ylabel(0(0.02).06) xtitle("") ///
title("Crime prior", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(crime,replace)

*Do welfare priors sum to 100?
gen sum_welfare_prior = welfareprior_western + welfareprior_danes + welfareprior

hist sum_welfare_prior, color(gs12) lcolor(black) ///
graphregion(color(white) margin(tiny)) plotregion(fcolor(white) lcolor(black)) ///
bgcolor(white) ylabel(, nogrid) yscale(r(0(.2).06)) ylabel(0(0.02).06) xtitle("") ///
title("Welfare prior", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(welf,replace)

*Do size priors sum to 100?
gen sum_share_prior = sizeprior_western + sizeprior_danes + numberprior

hist sum_share_prior,color(gs12) lcolor(black) ///
graphregion(color(white) margin(tiny)) plotregion(fcolor(white) lcolor(black)) ///
bgcolor(white) ylabel(, nogrid) yscale(r(0(.2).06)) ylabel(0(0.02).06) xtitle("") ///
title("Size prior", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(size,replace)


*We do the same for the posteriors
*Do crime posteriors sum to 100?
gen sum_crime_posterior = crimepost_western + crimepost_danes + crimeposterior

hist sum_crime_posterior, color(gs12) lcolor(black) ///
graphregion(color(white) margin(tiny)) plotregion(fcolor(white) lcolor(black)) ///
bgcolor(white) ylabel(, nogrid) yscale(r(0(.2).06)) ylabel(0(0.02).06) xtitle("") ///
title("Crime posterior", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(crime_p,replace)

*Do welfare posteriors sum to 100?
gen sum_welfare_posterior = welfarepost_western + welfarepost_danes + welfareposterior

hist sum_welfare_posterior,color(gs12) lcolor(black) ///
graphregion(color(white) margin(tiny)) plotregion(fcolor(white) lcolor(black)) ///
bgcolor(white) ylabel(, nogrid) yscale(r(0(.2).06)) ylabel(0(0.02).06) xtitle("") ///
title("Welfare posterior", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(welf_p,replace)

*Do size posteriors sum to 100?
gen sum_share_posterior = sizepost_western + sizepost_danes + numberposterior

hist sum_share_posterior,color(gs12) lcolor(black) ///
graphregion(color(white) margin(tiny)) plotregion(fcolor(white) lcolor(black)) ///
bgcolor(white) ylabel(, nogrid) yscale(r(0(.2).06)) ylabel(0(0.02).06) xtitle("") ///
title("Size posterior", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(size_p,replace)


*Finally we combine all the plots into one. Figure B.1:
graph combine welf welf_p crime crime_p size size_p,row(3) imargin(1 1 1 1) graphregion(margin(tiny)) plotregion(margin(tiny)) ///
graphregion(color(white)) plotregion(fcolor(white)) 

*save data set to keep the new variables*
save"correcting_misperception_recoded.dta",replace


*Figure B.2
//Prior Expectations by Immigrant Group.
//Here we plot the priors by immigrant group to show that participants' are in 
//fact able to distinguish between different groups of immigrants (Western vs. non-Western)

*Welfare exoeriment
gr twoway (kdensity welfareprior if eth1 == 1, kernel(gaussian) lcolor(black) lpattern(solid)) ///
kdensity welfareprior_western if eth1 == 1, kernel(gaussian) lcolor(gs12) lpattern(solid)  ///
legend(order(1 "Non-Western" 2 "Western") ///
 position(1) row(4) ring(0) size(vsmall) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
xlabel(,valuelabels angle(0) labsize(small)) ///
yscale(r(0(0.02).06)) ylabel(0(0.02)0.06) ///
ylabel(,valuelabels labsize(small) nogrid) ///
xtitle("") ///
xline(14, lpattern(dash)) ///
ytitle("Density", size(small)) ///
graphregion(margin(small) color(white)) plotregion(lcolor(black)) ///
title("Welfare Experiment",size(medium) color(black) ///
box bexpand bcolor(gs14) lcolor(black)) name(welf,replace)
*Crime experiment
gr twoway (kdensity crimeprior if eth1 == 1, kernel(gaussian) lcolor(black) lpattern(solid)) ///
kdensity crimeprior_western if eth1 == 1, kernel(gaussian) lcolor(gs12) lpattern(solid)  ///
legend(order(1 "Non-Western" 2 "Western") ///
 position(1) row(4) ring(0) size(vsmall) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
xlabel(,valuelabels angle(0) labsize(small)) ///
xline(21, lpattern(dash)) ///
yscale(r(0(0.02).06)) ylabel(0(0.02)0.06) ///
ylabel(,valuelabels labsize(small) nogrid) ///
xtitle("") ///
ytitle("Density", size(small)) ///
graphregion(margin(small) color(white)) plotregion(lcolor(black)) ///
title("Crime Experiment",size(medium) color(black) ///
box bexpand bcolor(gs14) lcolor(black)) name(crime,replace)
*Size experiment
gr twoway (kdensity numberprior if eth1 == 1, kernel(gaussian) lcolor(black) lpattern(solid)) ///
kdensity sizeprior_western if eth1 == 1, kernel(gaussian) lcolor(gs12) lpattern(solid)  ///
legend(order(1 "Non-Western" 2 "Western") ///
 position(1) row(4) ring(0) size(vsmall) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
xlabel(,valuelabels angle(0) labsize(small)) ///
xline(8, lpattern(dash)) ///
yscale(r(0(0.02).06)) ylabel(0(0.02)0.06) ///
ylabel(,valuelabels labsize(small) nogrid) ///
xtitle("") ///
ytitle("Density", size(small)) ///
graphregion(margin(small) color(white)) plotregion(lcolor(black)) ///
title("Size Experiment",size(medium) color(black) ///
box bexpand bcolor(gs14) lcolor(black)) name(size,replace)

*Combine the three panels into one plot. Figure B.2:
graph combine welf crime size,row(2) imargin(1 1 1 1) graphregion(margin(tiny)) plotregion(margin(tiny)) ///
graphregion(color(white)) plotregion(fcolor(white)) 


*Figure B.3
//Predictors of Prior Beliefs.
//Here we show each pre-measured covariate's correlation with the priors

*first we construct an indicator to only include the same observations
reg crimeprior gender age ideology  Income i.Education if eth1==1
g include=e(sample)
*second we standardize each predictor 
foreach var of varlist age ideology Income {
sum `var' if eth1==1  & include==1
replace `var'=(`var'-r(mean))/r(sd)
}
*third we extract the correlations from multivariate regression between the 
//priors and the predictors
reg welfareprior gender age ideology Income i.Education if eth1==1 & include==1
est sto welfare
reg crimeprior gender age ideology  Income i.Education if eth1==1
est sto crime
reg numberprior gender age ideology  Income i.Education if eth1==1  & include==1
est sto number
*fourth we plot all the coefs. Figure B.3:
coefplot (welfare,mcolor(black) levels(95) ciopts(color(black)) drop(_cons)) || ///
(crime,mcolor(black) levels(95) ciopts(color(black)) drop(_cons)) ||  ///
(number,mcolor(black) levels(95) ciopts(color(black)) drop(_cons))  ///
, byopts(row(1)) grid(no)  ///
legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(-20(10)10)) xlabel(-20(10)10) ///
coeflabels(gender="Sex (male)" age="Age" ideology="Ideology (1 sd)" ///
Income = "Income (1 sd)" 2.Education="Vocational training" 3.Education="High school" 4.Education="Higher education (short)" ///
5.Education="Higher education (medium)" 6.Education="Higher education (long)") ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
name(predictors,replace)


*Figure B.4. 
//Posterior beliefs by treatment status with confidence intervals
//Here we replicate Figure 1 in the manuscript but include CIs
//If not already installed, type "ssc install kdens" and "ssc install moremata"
*Welfare experiment
kdens welfareposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==0 ///
& crime_treatment==0, g(d0 x0) ci(ci0_l ci0_h) vce(boot,reps(1000)) kernel(gaussian) bw(silverman) range(0 100) 
kdens welfareposterior if eth1 == 1 & welfare_treatment==1 & number_treatment==0 ///
& crime_treatment==0,g(d1 x1) ci(ci1_l ci1_h) vce(boot,reps(1000)) kernel(gaussian) bw(silverman) range(0 100)
twoway rarea ci0_l ci0_h x0, color(gs12%60) || ///
rarea ci1_l ci1_h x1, color(black%80) || ///
 line d0 x0, lcolor(gs12) || line d1 x1,lcolor(black) ///
 legend(order(1 "Treatment prior" 2 "Treatment posterior") ///
 position(1) row(4) ring(0) size(vsmall) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
 xlabel(,valuelabels angle(0) labsize(small)) ///
yscale(r(0(0.005).03)) ylabel(0(0.01)0.04) ///
ylabel(,valuelabels labsize(small) nogrid) ///
xline(14, lcolor(black) lpattern(shortdash)) ///
xtitle("") ///
ytitle("Density", size(small)) ///
graphregion(margin(small) color(white)) plotregion(lcolor(black)) ///
title("Welfare Experiment",size(medium) color(black) ///
box bexpand bcolor(gs14) lcolor(black)) name(welf_exp,replace)

*Crime experiment
drop d0 x0 ci0_l ci0_h d1 x1 ci1_l ci1_h
kdens crimeposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==0 ///
& crime_treatment==1, g(d0 x0) ci(ci0_l ci0_h) vce(boot,reps(1000)) kernel(gaussian) bw(silverman) range(0 100) 
kdens crimeposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==0 ///
& crime_treatment==0,g(d1 x1) ci(ci1_l ci1_h) vce(boot,reps(1000)) kernel(gaussian) bw(silverman) range(0 100)
twoway rarea ci0_l ci0_h x0, color(gs12%60) || ///
rarea ci1_l ci1_h x1, color(black%80) || ///
 line d0 x0, lcolor(gs12) || line d1 x1,lcolor(black) ///
 legend(order(1 "Treatment prior" 2 "Treatment posterior") ///
 position(1) row(4) ring(0) size(vsmall) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
 xlabel(,valuelabels angle(0) labsize(small)) ///
yscale(r(0(0.005).03)) ylabel(0(0.01)0.04) ///
ylabel(,valuelabels labsize(small) nogrid) ///
xline(21, lcolor(black) lpattern(shortdash)) ///
xtitle("") ///
ytitle("Density", size(small)) ///
graphregion(margin(small) color(white)) plotregion(lcolor(black)) ///
title("Crime Experiment",size(medium) color(black) ///
box bexpand bcolor(gs14) lcolor(black)) name(crime_exp,replace)

*Size experiment
drop d0 x0 ci0_l ci0_h d1 x1 ci1_l ci1_h
kdens numberposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==0 ///
& crime_treatment==0, g(d0 x0) ci(ci0_l ci0_h) vce(boot,reps(1000)) kernel(gaussian) bw(silverman) range(0 100) 
kdens numberposterior if eth1 == 1 & welfare_treatment==0 & number_treatment==1 ///
& crime_treatment==0,g(d1 x1) ci(ci1_l ci1_h) vce(boot,reps(1000)) kernel(gaussian) bw(silverman) range(0 100)
twoway rarea ci0_l ci0_h x0, color(gs12%60) || ///
rarea ci1_l ci1_h x1, color(black%80) || ///
 line d0 x0, lcolor(gs12) || line d1 x1,lcolor(black) ///
 legend(order(1 "Treatment prior" 2 "Treatment posterior") ///
 position(1) row(4) ring(0) size(vsmall) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
 xlabel(,valuelabels angle(0) labsize(small)) ///
yscale(r(0(0.01).04)) ylabel(0(0.01)0.04) ///
ylabel(,valuelabels labsize(small) nogrid) ///
xline(9, lcolor(black) lpattern(shortdash)) ///
xtitle("") ///
ytitle("Density", size(small)) ///
graphregion(margin(small) color(white)) plotregion(lcolor(black)) ///
title("Size Experiment",size(medium) color(black) ///
box bexpand bcolor(gs14) lcolor(black)) name(num_exp,replace)

*We combine the three plots into one. Figure B.4:
graph combine welf_exp crime_exp num_exp ///
, row(2) graphregion(margin(tiny) color(white)) plotregion(margin(zero) color(white))


***************************************
*Appendix B.3. Covariate Balance Tests*
***************************************
//Here we show the correlation between each pre-measured covariate and the 
//respective information treatments

*For each experiment, we first generate variables to contain the estimated 
*correlations, standard errors, p-values, and confidence intervals
*welfare treatment
g betas_w=.
g ses_w=. 
g pv_w=.
g l95_w=.
g u95_w=.
*crime
g betas_c=.
g ses_c=. 
g pv_c=.
g l95_c=.
g u95_c=.
*size
g betas_n=.
g ses_n=. 
g pv_n=.
g l95_n=.
g u95_n=.

*Second we generate an 'identifier'
g p_outcome="gender" in 1
replace p_outcome="age" in 2 
replace p_outcome="welfareprior" in 3 
replace p_outcome="crimeprior" in 4
replace p_outcome="numberprior" in 5
replace p_outcome="ideology" in 6
replace p_outcome="ny_pol" in 7
replace p_outcome="a_ko_pol" in 8
replace p_outcome="Income" in 9
*parti
tab party_id,g(d_party)
codebook party_id,tab(15)
replace p_outcome="d_party1" in 13
replace p_outcome="d_party2" in 14
replace p_outcome="d_party3" in 15
replace p_outcome="d_party4" in 16
replace p_outcome="d_party5" in 17
replace p_outcome="d_party6" in 18
replace p_outcome="d_party7" in 19
replace p_outcome="d_party8" in 20
replace p_outcome="d_party9" in 21
replace p_outcome="d_party10" in 22
replace p_outcome="d_party11" in 23
replace p_outcome="d_party12" in 24

*education
tab Education,g(d_edu) // a lot of missing - need to handle
replace p_outcome="d_edu1" in 25
replace p_outcome="d_edu2" in 26
replace p_outcome="d_edu3" in 27
replace p_outcome="d_edu4" in 28
replace p_outcome="d_edu5" in 29
replace p_outcome="d_edu6" in 30


*Third we regress each placebo outcome on the respective treatments and extract 
*the correlations, ses, p-values, and confidence intervals

*welfare treatment
foreach var of varlist gender age welfareprior crimeprior numberprior ///
ideology ny_pol a_ko_pol Income d_party1 d_party2 d_party3 d_party4 ///
d_party5 d_party6 d_party7 d_party8 d_party9 d_party10 d_party11 d_party12 ///
d_edu1 d_edu2 d_edu3 d_edu4 d_edu5 d_edu6 {
local vl "gender age welfareprior crimeprior numberprior ideology ny_pol a_ko_pol income d_party1 d_party2 d_party3 d_party4 d_party5 d_party6 d_party7 d_party8 d_party9 d_party10 d_party11 d_party12 d_edu1 d_edu2 d_edu3 d_edu4 d_edu5 d_edu6"
local exclude "`var'"
local vl: list vl - exclude
reg `var' welfare_treatment if eth1 == 1 & number_treatment==0 & crime_treatment==0
qui mat A =e(b)
qui mat B=e(V)
qui replace betas_w=A[1,1] if p_outcome=="`var'"
qui replace ses_w=sqrt(B[1,1]) if p_outcome=="`var'"
qui replace pv_w=2*(1-normal(abs(betas_w/ses_w))) if p_outcome=="`var'"
qui replace u95_w=betas_w+(1.96*ses_w) if p_outcome=="`var'"
qui replace l95_w=betas_w-(1.96*ses_w) if p_outcome=="`var'"
}
*
*crimne treatment
foreach var of varlist gender age welfareprior crimeprior numberprior ///
ideology ny_pol a_ko_pol Income d_party1 d_party2 d_party3 d_party4 ///
d_party5 d_party6 d_party7 d_party8 d_party9 d_party10 d_party11 d_party12 ///
d_edu1 d_edu2 d_edu3 d_edu4 d_edu5 d_edu6 {
local vl "gender age welfareprior crimeprior numberprior ideology ny_pol a_ko_pol income d_party1 d_party2 d_party3 d_party4 d_party5 d_party6 d_party7 d_party8 d_party9 d_party10 d_party11 d_party12 d_edu1 d_edu2 d_edu3 d_edu4 d_edu5 d_edu6"
local exclude "`var'"
local vl: list vl - exclude
reg `var' crime_treatment if eth1 == 1 & number_treatment==0 & welfare_treatment==0
qui mat A =e(b)
qui mat B=e(V)
qui replace betas_c=A[1,1] if p_outcome=="`var'"
qui replace ses_c=sqrt(B[1,1]) if p_outcome=="`var'"
qui replace pv_c=2*(1-normal(abs(betas_c/ses_c))) if p_outcome=="`var'"
qui replace u95_c=betas_c+(1.96*ses_c) if p_outcome=="`var'"
qui replace l95_c=betas_c-(1.96*ses_c) if p_outcome=="`var'"
}
*
*size treatment
foreach var of varlist gender age welfareprior crimeprior numberprior ///
ideology ny_pol a_ko_pol Income d_party1 d_party2 d_party3 d_party4 ///
d_party5 d_party6 d_party7 d_party8 d_party9 d_party10 d_party11 d_party12 ///
d_edu1 d_edu2 d_edu3 d_edu4 d_edu5 d_edu6 {
local vl "gender age welfareprior crimeprior numberprior ideology ny_pol a_ko_pol income d_party1 d_party2 d_party3 d_party4 d_party5 d_party6 d_party7 d_party8 d_party9 d_party10 d_party11 d_party12 d_edu1 d_edu2 d_edu3 d_edu4 d_edu5 d_edu6"
local exclude "`var'"
local vl: list vl - exclude
reg `var' crime_treatment if eth1 == 1 & number_treatment==0 & welfare_treatment==0
qui mat A =e(b)
qui mat B=e(V)
qui replace betas_n=A[1,1] if p_outcome=="`var'"
qui replace ses_n=sqrt(B[1,1]) if p_outcome=="`var'"
qui replace pv_n=2*(1-normal(abs(betas_n/ses_n))) if p_outcome=="`var'"
qui replace u95_n=betas_n+(1.96*ses_n) if p_outcome=="`var'"
qui replace l95_n=betas_n-(1.96*ses_n) if p_outcome=="`var'"
}
*
*keep only the relevant parameters
drop if p_outcome==""
*we rescale some of the parameters for output purposes
*welfare priors (betas)
replace betas_w=betas_w/100 if p_outcome=="welfareprior"
replace betas_c=betas_c/100 if p_outcome=="welfareprior"
replace betas_n=betas_n/100 if p_outcome=="welfareprior"
*crime priors (betas)
replace betas_c=betas_c/100 if p_outcome=="crimeprior"
replace betas_w=betas_w/100 if p_outcome=="crimeprior"
replace betas_n=betas_n/100 if p_outcome=="crimeprior"
*size priors (betas)
replace betas_n=betas_n/100 if p_outcome=="numberprior"
replace betas_c=betas_c/100 if p_outcome=="numberprior"
replace betas_w=betas_w/100 if p_outcome=="numberprior"
*welfare priors (upper CIs)
replace u95_w=u95_w/100 if p_outcome=="welfareprior"
replace u95_c=u95_c/100 if p_outcome=="welfareprior"
replace u95_n=u95_n/100 if p_outcome=="welfareprior"
*crime priors (upper CIs)
replace u95_c=u95_c/100 if p_outcome=="crimeprior"
replace u95_w=u95_w/100 if p_outcome=="crimeprior"
replace u95_n=u95_n/100 if p_outcome=="crimeprior"
*size priors (upper CIs)
replace u95_n=u95_n/100 if p_outcome=="numberprior"
replace u95_w=u95_w/100 if p_outcome=="numberprior"
replace u95_c=u95_c/100 if p_outcome=="numberprior"
*welfare priors (lower CIs)
replace l95_w=l95_w/100 if p_outcome=="welfareprior"
replace l95_c=l95_c/100 if p_outcome=="welfareprior"
replace l95_n=l95_n/100 if p_outcome=="welfareprior"
*crime priors (lower CIs)´
replace l95_c=l95_c/100 if p_outcome=="crimeprior"
replace l95_w=l95_w/100 if p_outcome=="crimeprior"
replace l95_n=l95_n/100 if p_outcome=="crimeprior"
*size priors (lower CIs)
replace l95_n=l95_n/100 if p_outcome=="numberprior"
replace l95_c=l95_c/100 if p_outcome=="numberprior"
replace l95_w=l95_w/100 if p_outcome=="numberprior"
*Age (betas)
replace betas_w=betas_w/10 if p_outcome=="age"
replace betas_c=betas_c/10 if p_outcome=="age"
replace betas_n=betas_n/10 if p_outcome=="age"
*age (uper CIs)
replace u95_w=u95_w/10 if p_outcome=="age"
replace u95_c=u95_c/10 if p_outcome=="age"
replace u95_n=u95_n/10 if p_outcome=="age"
*age (lower CIs)
replace l95_w=l95_w/10 if p_outcome=="age"
replace l95_c=l95_c/10 if p_outcome=="age"
replace l95_n=l95_n/10 if p_outcome=="age"
*ideology(betas)
replace betas_w=betas_w/10 if p_outcome=="ideology"
replace betas_c=betas_c/10 if p_outcome=="ideology"
replace betas_n=betas_n/10 if p_outcome=="ideology"
*ideology (uper CIs)
replace u95_w=u95_w/10 if p_outcome=="ideology"
replace u95_c=u95_c/10 if p_outcome=="ideology"
replace u95_n=u95_n/10 if p_outcome=="ideology"
*ideology (lower CIs)
replace l95_w=l95_w/10 if p_outcome=="ideology"
replace l95_c=l95_c/10 if p_outcome=="ideology"
replace l95_n=l95_n/10 if p_outcome=="ideology"
*soc. ideology (betas)
replace betas_w=betas_w/10 if p_outcome=="ny_pol"
replace betas_c=betas_c/10 if p_outcome=="ny_pol"
replace betas_n=betas_n/10 if p_outcome=="ny_pol"
*soc. ideology (uper CIs)
replace u95_w=u95_w/10 if p_outcome=="ny_pol"
replace u95_c=u95_c/10 if p_outcome=="ny_pol"
replace u95_n=u95_n/10 if p_outcome=="ny_pol"
*soc. ideology (lower CIs)
replace l95_w=l95_w/10 if p_outcome=="ny_pol"
replace l95_c=l95_c/10 if p_outcome=="ny_pol"
replace l95_n=l95_n/10 if p_outcome=="ny_pol"
*econ ideology (betas)
replace betas_w=betas_w/10 if p_outcome=="a_ko_pol"
replace betas_c=betas_c/10 if p_outcome=="a_ko_pol"
replace betas_n=betas_n/10 if p_outcome=="a_ko_pol"
*econ ideology (uper CIs)
replace u95_w=u95_w/10 if p_outcome=="a_ko_pol"
replace u95_c=u95_c/10 if p_outcome=="a_ko_pol"
replace u95_n=u95_n/10 if p_outcome=="a_ko_pol"
*econ ideology (lower CIs)
replace l95_w=l95_w/10 if p_outcome=="a_ko_pol"
replace l95_c=l95_c/10 if p_outcome=="a_ko_pol"
replace l95_n=l95_n/10 if p_outcome=="a_ko_pol"
*income (betas)
replace betas_w=betas_w/10 if p_outcome=="Income"
replace betas_c=betas_c/10 if p_outcome=="Income"
replace betas_n=betas_n/10 if p_outcome=="Income"
*income (uper CIs)
replace u95_w=u95_w/10 if p_outcome=="Income"
replace u95_c=u95_c/10 if p_outcome=="Income"
replace u95_n=u95_n/10 if p_outcome=="Income"
*income (lower CIs)
replace l95_w=l95_w/10 if p_outcome=="Income"
replace l95_c=l95_c/10 if p_outcome=="Income"
replace l95_n=l95_n/10 if p_outcome=="Income"



*Here we construct three matrices that we can plot. One for each experiment.
mkmat betas_w l95_w u95_w, matrix(A)
mkmat betas_c l95_c u95_c, matrix(B)
mkmat betas_n l95_n u95_n, matrix(C)

*Below we plot each matrix.
mat rownames A = Gender Age Welfareprior Crimeprior Numberprior Ideology Social_Ideology ///
Economic_Ideology Income Socialdemokratiet Det_Radikale_Venstre Det_Konservative_Folkeparti ///
Socialistisk_Folkeparti Liberal_Alliance Kristendemokraterne Dansk_Folkeparti Venstre ///
Enhedslisten Alternativet Other_party No_party Primary_School Vocational_training Highschool ///
Higher_education_(short) Higher_education_(medium) Higher_education_(long)
mat rownames B = Gender Age Welfareprior Crimeprior Numberprior Ideology Social_Ideology ///
Economic_Ideology Income Socialdemokratiet Det_Radikale_Venstre Det_Konservative_Folkeparti ///
Socialistisk_Folkeparti Liberal_Alliance Kristendemokraterne Dansk_Folkeparti Venstre ///
Enhedslisten Alternativet Other_party No_party Primary_School Vocational_training Highschool ///
Higher_education_(short) Higher_education_(medium) Higher_education_(long)
mat rownames C = Gender Age Welfareprior Crimeprior Numberprior Ideology Social_Ideology ///
Economic_Ideology Income Socialdemokratiet Det_Radikale_Venstre Det_Konservative_Folkeparti ///
Socialistisk_Folkeparti Liberal_Alliance Kristendemokraterne Dansk_Folkeparti Venstre ///
Enhedslisten Alternativet Other_party No_party Primary_School Vocational_training Highschool ///
Higher_education_(short) Higher_education_(medium) Higher_education_(long)

*Finally we combine the plots into one. Figure B.5:
coefplot (matrix(A[.,1]), color(black) msymbol(circle) ciopts(color(black)) ci((A[.,2] A[.,3]))) || ///
(matrix(B[.,1]),  ci((B[.,2] B[.,3]))) || ///
(matrix(C[.,1]), ci((C[.,2] C[.,3]))), byopts(row(1)) ///
xline(0, lpattern(dash) lcolor(black)) ///
transform(* = min(max(@,-.25),.25)) xscale(range(-.25 (.25) .25)) plotregion(margin(zero)) ///
headings(Socialdemokratiet="{bf:Party}" Primary_School="{bf:Education}") ///
coeflabels(Gender="Sex" Age="Age (/10)" Welfareprior="Welfareprior (/100)" Crimeprior="Crimeeprior (/100)" ///
Numberprior="Sizeprior (/100)" Ideology="Ideology (/10)" Social_Ideology="Social ideology (/10)" Economic_Ideology="Economic ideology (/10)" ///
Income="Income 1000s (/10)" Det_Radikale_Venstre="Det Radikale Venstre" Det_Konservative_Folkeparti="Det Konservative Folkeparti" ///
Socialistisk_Folkeparti="Socialistisk Folkeparti" Dansk_Folkeparti="Dansk Folkeparti" Other_party="Other party" No_party="No party" ///
Primary_School="Primary school" Vocational_training="Vocational training" Higher_education_(short)="Higher education (short)" ///
Higher_education_(medium)="Higher education (medium)" Higher_education_(long)="Higher education (long)") ///
ylab(,valuelabels labsize(medsmall) nogrid) ///
xlab(,valuelabels labsize(medsmall) nogrid) grid(no) ///
xtitle("placebo outcome effect", size(medsmall)) ///
graphregion(fcolor(white) margin(tiny) lcolor(white)) ///
plotregion(fcolor(white) lcolor(black) margin(zero)) ///
name(placebooutcomes,replace)


*Reload data
use "correcting_misperception_recoded.dta",clear //use data set with recoded variables
*

**************************************
*Appendix B.5. Updating of Posteriors*
**************************************
//Here we provide supplementary results for the results in the manuscript.  
//The effects of Table B.1 corresponds to the effects of Figure 2 
//in the manuscript. The results, for each posterior respectively, 
//can be replicated by running the following code:

*Welfare Posterior (upper panel of Table B.1):
*average effect of treatment across the categories of the prior
reg c_welfarepost welfare_treatment   if eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto overall
*effect among underestimators
reg c_welfarepost welfare_treatment if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto underestimators
*effect among small overestimators
reg c_welfarepost welfare_treatment  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto small
*effect among moderate overestimators
reg c_welfarepost welfare_treatment  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto moderate
*effect among large overestimators
reg c_welfarepost welfare_treatment  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto large
*Upper panel of Table B.1:
esttab overall underestimators small moderate large, se label title("Welfare Posterior") mtitle("Full Sample" "Bias<0" "Small Overestimation" "Moderate Overestimation" "Large Overestimation") drop(_cons)

*outcome means and ses
sum c_welfarepost   if eth1 == 1 & number_treatment==0 & crime_treatment==0 
sum c_welfarepost   if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0 
sum c_welfarepost   if  welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0 
sum c_welfarepost   if  welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0 
sum c_welfarepost   if  welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0 



*Crime Posterior (middle panel of Table B.1):
reg c_crimepost crime_treatment  if eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto overall_c
*effect among underestimators
reg c_crimepost crime_treatment  if crime_cat==0 & eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto underestimators_c
*effect among small overestimators
reg c_crimepost crime_treatment  if crime_cat==1 & eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto small_c
*effect among moderate overestimators 
reg c_crimepost crime_treatment  if crime_cat==2 & eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto moderate_c
*effect among large overestimators
reg c_crimepost crime_treatment  if crime_cat==3 & eth1 == 1 & welfare_treatment==0 & number_treatment==0,r
est sto large_c
*Middle panel of Table B.1:
esttab overall_c underestimators_c small_c moderate_c large_c, se label title("Crime Posterior") mtitle("Full Sample" "Bias<0" "Small Overestimation" "Moderate Overestimation" "Large Overestimation") drop(_cons)

*outcome means and ses
sum c_crimepost   if eth1 == 1 & number_treatment==0 & welfare_treatment==0 
sum c_crimepost   if crime_cat==0 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 
sum c_crimepost   if  crime_cat==1 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 
sum c_crimepost   if  crime_cat==2 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 
sum c_crimepost   if  crime_cat==3 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 


*Size Posterior (Lower panel of Table B.1):
reg c_numpost number_treatment  if eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto overall_n
*effect among underestimators
reg c_numpost number_treatment   if num_cat==0 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto underestimators_n
*effect among small overestimators
reg c_numpost number_treatment  if num_cat==1 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto small_n
*effect among moderate overestimators
reg c_numpost number_treatment  if num_cat==2 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto moderate_n
*effect among large overestimators
reg c_numpost number_treatment   if num_cat==3 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0,r
est sto large_n
*Lower panel of Table B.1:
esttab overall_n underestimators_n small_n moderate_n large_n, se label title("Size Posterior") mtitle("Full Sample" "Bias<0" "Small Overestimation" "Moderate Overestimation" "Large Overestimation") drop(_cons)

*outcome means and ses
sum c_numpost   if eth1 == 1 & welfare_treatment==0 & crime_treatment==0 
sum c_numpost   if num_cat==0 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 
sum c_numpost   if  num_cat==1 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 
sum c_numpost   if  num_cat==2 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 
sum c_numpost   if  num_cat==3 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 


**************************
*Table B.2 and Figure B.6*
************************** 
//Below, we provide code to construct the robustness analyses that 
//supplements the main findings.
//Linear estimation of the interaction between the treatments and priors

*Table B.2:
reg c_welfarepost welfare_treatment c_welfareprior welfare_treatment#c.c_welfareprior if crime_treatment == 0 ///
& number_treatment == 0 & eth1 == 1  , r
est sto welfare
*
reg c_crimepost crime_treatment c_crimeprior crime_treatment#c.c_crimeprior  ///
if number_treatment == 0 ///
& welfare_treatment == 0 & eth1 == 1  ,r 
est sto crime
*
reg c_numpost number_treatment c_numberprior number_treatment#c.c_numberprior  ///
if crime_treatment == 0 ///
& welfare_treatment == 0 & eth1 == 1 , r
est sto size

*table B.2:
esttab welfare crime size, se label title("Table B.2") mtitle("Welfare Posterior" "Crime Posterior" "Size Posterior") ///
drop(_cons 0.welfare_treatment#c.c_welfareprior 0.crime_treatment#c.c_crimeprior 0.number_treatment#c.c_numberprior)


*Figure B.6
*Welfare experiment
//First column of Table B.2 
//Top left panel of Figure B.6
*run regression
reg c_welfarepost c.c_welfareprior##welfare_treatment if crime_treatment == 0 ///
& number_treatment == 0 & eth1 == 1  ,r
margins, dydx(welfare_treatment) at(c_welfareprior=(-0.14(0.10)0.86)) 
marginsplot
*get marginal effects at different levels of the prior
est store Welfare_immigration_fear_2
mat a = r(table)'
svmat a, name(col)
mat at_ = r(at)
svmat at_, name(col_)
g c_welf1=.
replace c_welf1=-.14 in 12
replace c_welf1=-.04 in 13
replace c_welf1= .06 in 14
replace c_welf1= .16 in 15
replace c_welf1= .26 in 16
replace c_welf1= .36 in 17
replace c_welf1= .46 in 18
replace c_welf1= .56 in 19
replace c_welf1= .66 in 20
replace c_welf1= .76 in 21
replace c_welf1= .86 in 22
*plot the marginal effects on the distribution of the prior
twoway histogram c_welfareprior if crime_treatment == 0 ///
& number_treatment == 0 & eth1 == 1, yaxis(2) lcolor(gray) bcolor(gs14) || ///
line b c_welf1,sort(c_welf1) lcolor(black) ///
|| line ul c_welf1,sort(c_welf1) lcolor(black) lpattern(dash) ytitle(Marginal Effect of Treatment) ///
|| line ll c_welf1,sort(c_welf1) lcolor(black) lpattern(dash) ///
legend(off) xlabel(,valuelabels  labsize(medsmall)) ///
ylabel(,valuelabels labsize(medsmall) nogrid) ///
ylabel(,axis(2) valuelabels angle(0) labsize(medsmall) nogrid) ///
yscale(r(-.2(0.1).1)) ylabel(-.2(0.1).1) ///
xtitle("Welfare prior", size(medsmall)) ///
ytitle("Marginal Effect of Treatment", size(medsmall)) ///
ytitle("Density", axis(2) size(medsmall)) ///
graphregion(margin(zero)) plotregion(lcolor(black)) ///
graphregion(color(white)) plotregion(fcolor(white)) ///
bgcolor(white) ///
title("Welfare experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(welf_exp,replace) 

*Crime experiment
//do the same as above for the crime experiment
//second colum of Table B.2 and top right panel of Figure B.6
reg c_crimepost c.c_crimeprior##crime_treatment  ///
if number_treatment == 0 ///
& welfare_treatment == 0 & eth1 == 1 ,r
margins, dydx(crime_treatment) at(c_crimeprior=(-0.21(0.10)0.79)) post
mat A=r(table)
mat B= A[1,12],A[5,12],A[6,12]\A[1,13],A[5,13],A[6,13]\A[1,14],A[5,14],A[6,14]\A[1,15],A[5,15],A[6,15] ///
\A[1,16],A[5,16],A[6,16]\A[1,17],A[5,17],A[6,17]\A[1,18],A[5,18],A[6,18] ///
\A[1,19],A[5,19],A[6,19]\A[1,20],A[5,20],A[6,20]\A[1,21],A[5,21],A[6,21] ///
\A[1,22],A[5,22],A[6,22]
matlist B
matrix colnames B = est_pc l95_pc u95_pc
svmat B,name(col__)
*
g c_welf2=.
replace c_welf2=-.21 in 1
replace c_welf2=-.11 in 2
replace c_welf2= -.01 in 3
replace c_welf2= .09 in 4
replace c_welf2= .19 in 5
replace c_welf2= .29 in 6
replace c_welf2= .39 in 7
replace c_welf2= .49 in 8
replace c_welf2= .59 in 9
replace c_welf2= .69 in 10
replace c_welf2= .79 in 11
*
twoway histogram c_crimeprior if welfare_treatment==0 ///
& number_treatment == 0 & eth1 == 1  , yaxis(2) lcolor(gray) bcolor(gs14) ///
|| line col__1 c_welf2,sort(c_welf2) lcolor(black) ///
|| line col__2 c_welf2,sort(c_welf2) lcolor(black) lpattern(dash)  ///
|| line col__3 c_welf2,sort(c_welf2) lcolor(black) lpattern(dash) ///
legend(off) xlabel(,valuelabels  labsize(medsmall)) ///
ylabel(,valuelabels labsize(medsmall) nogrid) ///
ylabel(,axis(2) valuelabels angle(0) labsize(medsmall) nogrid) ///
yscale(r(-.2(0.1).1)) ylabel(-.2(0.1).1) ///
xtitle("Crime prior", size(medsmall)) ///
ytitle("Marginal Effect of Treatment", size(medsmall)) ///
ytitle("Density", axis(2) size(medsmall)) ///
graphregion(margin(zero)) plotregion(lcolor(black)) ///
graphregion(color(white)) plotregion(fcolor(white)) ///
bgcolor(white) ///
title("Crime experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(crime_exp,replace) 


*Size experiment
//do the same as above for the size experiment
//third colum of Table B.2 and bottom panel of Figure B.6
reg c_numpost c.c_numberprior##number_treatment  ///
if crime_treatment == 0 ///
& welfare_treatment == 0 & eth1 == 1 ,r
margins, dydx(number_treatment) at(c_numberprior=(-0.08(0.10)0.92)) post
mat A=r(table)
mat B= A[1,12],A[5,12],A[6,12]\A[1,13],A[5,13],A[6,13]\A[1,14],A[5,14],A[6,14]\A[1,15],A[5,15],A[6,15] ///
\A[1,16],A[5,16],A[6,16]\A[1,17],A[5,17],A[6,17]\A[1,18],A[5,18],A[6,18] ///
\A[1,19],A[5,19],A[6,19]\A[1,20],A[5,20],A[6,20]\A[1,21],A[5,21],A[6,21] ///
\A[1,22],A[5,22],A[6,22]
matlist B
matrix colnames B = est_pn l95_pn u95_pn
svmat B,name(col___)

g c_welf3=.
replace c_welf3=-.08 in 1
replace c_welf3=.02 in 2
replace c_welf3= .12 in 3
replace c_welf3= .22 in 4
replace c_welf3= .32 in 5
replace c_welf3= .42 in 6
replace c_welf3= .52 in 7
replace c_welf3= .62 in 8
replace c_welf3= .72 in 9
replace c_welf3= .82 in 10
replace c_welf3= .92 in 11

twoway histogram c_numberprior if welfare_treatment==0 ///
& crime_treatment == 0 & eth1 == 1  , yaxis(2) lcolor(gray) bcolor(gs14) ///
|| line col___1 c_welf3,sort(c_welf3) lcolor(black) ///
|| line col___2 c_welf3,sort(c_welf3) lcolor(black) lpattern(dash)  ///
|| line col___3 c_welf3,sort(c_welf3) lcolor(black) lpattern(dash) ///
legend(off) xlabel(,valuelabels  labsize(medsmall)) ///
ylabel(,valuelabels labsize(medsmall) nogrid) ///
ylabel(,axis(2) valuelabels angle(0) labsize(medsmall) nogrid) ///
yscale(r(-.2(0.1).1)) ylabel(-.2(0.1).1) ///
xtitle("Size prior", size(medsmall)) ///
ytitle("Marginal Effect of Treatment", size(medsmall)) ///
ytitle("Density", axis(2) size(medsmall)) ///
graphregion(margin(zero)) plotregion(lcolor(black)) ///
graphregion(color(white)) plotregion(fcolor(white)) ///
bgcolor(white) ///
title("Size experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(num_exp,replace) 

*Combine the three panel in one plot. Figure B.6: 
graph combine welf_exp crime_exp num_exp,row(2) imargin(1 1 1 1) graphregion(margin(tiny)) plotregion(margin(tiny)) ///
graphregion(color(white)) plotregion(fcolor(white)) 



************
*Figure B.7*
************
//Here we run the above effect by ethnic group to show that participants' in fact 
//distinguish between the different groups

*Welfare experiment
*first gen 'identifiers'
g overall=welfare_treatment
g underestimators=welfare_treatment
g small=welfare_treatment
g moderate=welfare_treatment
g large=welfare_treatment

*second estimate effects for each ethnic group while subsetting on prior expectations
*non-Western immigrants
reg welfareposterior overall   if eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto overall
reg welfareposterior underestimators  if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto underestimators
reg welfareposterior small  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto small
reg welfareposterior moderate  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto moderate
reg welfareposterior large  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto large
*Western immigrants
reg welfarepost_western overall   if eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto overall_n
reg welfarepost_western underestimators  if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto underestimators_n
reg welfarepost_western small  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto small_n
reg welfarepost_western moderate  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto moderate_n
reg welfarepost_western large  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto large_n
*Danes
reg welfarepost_danes overall   if eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto overall_d
reg welfarepost_danes welfare_treatment##i.welf_cat if eth1 == 1 & number_treatment==0 & crime_treatment==0,r
reg welfarepost_danes underestimators  if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto underestimators_d
reg welfarepost_danes small  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto small_d
reg welfarepost_danes moderate  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto moderate_d
reg welfarepost_danes large  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0,r
est sto large_d
*Plot the above coefs. Top left panel of Figure B.7
coefplot (overall,offset(.2) mcolor(black) keep(overall) levels(95) ciopts(color(black))) ///
(overall_n,offset(0) msymbol(triangle) mcolor(gs12) keep(overall) levels(95) ciopts(color(gs12))) ///
(overall_d,offset(-.2) msymbol(square) mcolor(gs8) keep(overall) levels(95) ciopts(color(gs8))) ///
(underestimators,offset(.2) mcolor(black) keep(underestimators) levels(95) ciopts(color(black))) ///
(underestimators_n,offset(0) msymbol(triangle) mcolor(gs12) keep(underestimators) levels(95) ciopts(color(gs12))) ///
(underestimators_d,offset(-.2) msymbol(square) mcolor(gs8) keep(underestimators) levels(95) ciopts(color(gs8))) ///
(small,offset(.2) mcolor(black) keep(small) levels(95) ciopts(color(black))) ///
(small_n,offset(0) msymbol(triangle) mcolor(gs12) keep(small) levels(95) ciopts(color(gs12))) ///
(small_d,offset(-.2) msymbol(square) mcolor(gs8) keep(small) levels(95) ciopts(color(gs8))) ///
(moderate,offset(.2) mcolor(black) keep(moderate) levels(95) ciopts(color(black))) ///
(moderate_n,offset(0) msymbol(triangle) mcolor(gs12) keep(moderate) levels(95) ciopts(color(gs12))) ///
(moderate_d,offset(-.2) msymbol(square) mcolor(gs8) keep(moderate) levels(95) ciopts(color(gs8))) ///
(large,offset(.2) mcolor(black) keep(large) levels(95) ciopts(color(black))) ///
(large_n,offset(0) msymbol(triangle) mcolor(gs12) keep(large) levels(95) ciopts(color(gs12))) ///
(large_d,offset(-.2) msymbol(square) mcolor(gs8) keep(large) levels(95) ciopts(color(gs8))) ///
, grid(no)  ///
legend(order(6 "Non-Western" 12 "Western") ///
position(1) row(4) ring(0) size(medium) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(20(10)20)) xlabel(-20(10)20) ///
coeflabels(overall = "Overall" underestimators = "Underestimators" ///
small = "Small overestimators" moderate = "Moderate overestimators" large = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Welfare experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(welfare_exp,replace)

*Crime experiment 
//Do the same as above, but for the crime information treatment
*
drop overall underestimators small moderate large
g overall=crime_treatment
g underestimators=crime_treatment
g small=crime_treatment
g moderate=crime_treatment
g large=crime_treatment
*
reg crimeposterior overall   if eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto overall
reg crimeposterior underestimators  if welf_cat==0 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto underestimators
reg crimeposterior small  if crime_cat==1 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto small
reg crimeposterior moderate  if crime_cat==2 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto moderate
reg crimeposterior large  if crime_cat==3 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto large
*
reg crimepost_western overall   if eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto overall_n
reg crimepost_western underestimators  if welf_cat==0 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto underestimators_n
reg crimepost_western small  if crime_cat==1 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto small_n
reg crimepost_western moderate  if crime_cat==2 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto moderate_n
reg crimepost_western large  if crime_cat==3 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto large_n
*
reg crimepost_danes overall   if eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto overall_d
reg crimepost_danes underestimators  if welf_cat==0 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto underestimators_d
reg crimepost_danes small  if crime_cat==1 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto small_d
reg crimepost_danes moderate  if crime_cat==2 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto moderate_d
reg crimepost_danes large  if crime_cat==3 & eth1 == 1 & number_treatment==0 & welfare_treatment==0,r
est sto large_d
*Top right panel of Figure B.7:
coefplot (overall,offset(.2) mcolor(black) keep(overall) levels(95) ciopts(color(black))) ///
(overall_n,offset(0) msymbol(triangle) mcolor(gs12) keep(overall) levels(95) ciopts(color(gs12))) ///
(overall_d,offset(-.2) msymbol(square) mcolor(gs8) keep(overall) levels(95) ciopts(color(gs8))) ///
(underestimators,offset(.2) mcolor(black) keep(underestimators) levels(95) ciopts(color(black))) ///
(underestimators_n,offset(0) msymbol(triangle) mcolor(gs12) keep(underestimators) levels(95) ciopts(color(gs12))) ///
(underestimators_d,offset(-.2) msymbol(square) mcolor(gs8) keep(underestimators) levels(95) ciopts(color(gs8))) ///
(small,offset(.2) mcolor(black) keep(small) levels(95) ciopts(color(black))) ///
(small_n,offset(0) msymbol(triangle) mcolor(gs12) keep(small) levels(95) ciopts(color(gs12))) ///
(small_d,offset(-.2) msymbol(square) mcolor(gs8) keep(small) levels(95) ciopts(color(gs8))) ///
(moderate,offset(.2) mcolor(black) keep(moderate) levels(95) ciopts(color(black))) ///
(moderate_n,offset(0) msymbol(triangle) mcolor(gs12) keep(moderate) levels(95) ciopts(color(gs12))) ///
(moderate_d,offset(-.2) msymbol(square) mcolor(gs8) keep(moderate) levels(95) ciopts(color(gs8))) ///
(large,offset(.2) mcolor(black) keep(large) levels(95) ciopts(color(black))) ///
(large_n,offset(0) msymbol(triangle) mcolor(gs12) keep(large) levels(95) ciopts(color(gs12))) ///
(large_d,offset(-.2) msymbol(square) mcolor(gs8) keep(large) levels(95) ciopts(color(gs8))) ///
, grid(no)  ///
legend(order(6 "Non-Western" 12 "Western") ///
position(1) row(4) ring(0) size(medium) rowgap(tiny) region(lwidth(none) color(none) margin(zero))) ///
legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(20(10)20)) xlabel(-20(10)20) ///
yscale(alt) ///
coeflabels(overall = "Overall" underestimators = "Underestimators" ///
small = "Small overestimators" moderate = "Moderate overestimators" large = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Crime experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(crime_exp,replace)


*Size experiment. Doing the same as above but for the size treatment
drop overall underestimators small moderate large
g overall=number_treatment
g underestimators=number_treatment
g small=number_treatment
g moderate=number_treatment
g large=number_treatment
*
reg numberposterior overall   if eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto overall
reg numberposterior underestimators  if num_cat==0 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto underestimators
reg numberposterior small  if num_cat==1 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto small
reg numberposterior moderate  if num_cat==2 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto moderate
reg numberposterior large  if num_cat==3 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto large
*
reg sizepost_western overall   if eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto overall_n
reg sizepost_western underestimators  if welf_cat==0 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto underestimators_n
reg sizepost_western small  if welf_cat==1 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto small_n
reg sizepost_western moderate  if welf_cat==2 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto moderate_n
reg sizepost_western large  if welf_cat==3 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto large_n
*
reg sizepost_danes overall   if eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto overall_d
reg sizepost_danes underestimators  if welf_cat==0 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto underestimators_d
reg sizepost_danes small  if welf_cat==1 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto small_d
reg sizepost_danes moderate  if welf_cat==2 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto moderate_d
reg sizepost_danes large  if welf_cat==3 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0,r
est sto large_d
*Bottom panel of Figure B.7:
coefplot (overall,offset(.2) mcolor(black) keep(overall) levels(95) ciopts(color(black))) ///
(overall_n,offset(0) msymbol(triangle) mcolor(gs12) keep(overall) levels(95) ciopts(color(gs12))) ///
(overall_d,offset(-.2) msymbol(square) mcolor(gs8) keep(overall) levels(95) ciopts(color(gs8))) ///
(underestimators,offset(.2) mcolor(black) keep(underestimators) levels(95) ciopts(color(black))) ///
(underestimators_n,offset(0) msymbol(triangle) mcolor(gs12) keep(underestimators) levels(95) ciopts(color(gs12))) ///
(underestimators_d,offset(-.2) msymbol(square) mcolor(gs8) keep(underestimators) levels(95) ciopts(color(gs8))) ///
(small,offset(.2) mcolor(black) keep(small) levels(95) ciopts(color(black))) ///
(small_n,offset(0) msymbol(triangle) mcolor(gs12) keep(small) levels(95) ciopts(color(gs12))) ///
(small_d,offset(-.2) msymbol(square) mcolor(gs8) keep(small) levels(95) ciopts(color(gs8))) ///
(moderate,offset(.2) mcolor(black) keep(moderate) levels(95) ciopts(color(black))) ///
(moderate_n,offset(0) msymbol(triangle) mcolor(gs12) keep(moderate) levels(95) ciopts(color(gs12))) ///
(moderate_d,offset(-.2) msymbol(square) mcolor(gs8) keep(moderate) levels(95) ciopts(color(gs8))) ///
(large,offset(.2) mcolor(black) keep(large) levels(95) ciopts(color(black))) ///
(large_n,offset(0) msymbol(triangle) mcolor(gs12) keep(large) levels(95) ciopts(color(gs12))) ///
(large_d,offset(-.2) msymbol(square) mcolor(gs8) keep(large) levels(95) ciopts(color(gs8))) ///
, grid(no)  ///
legend(order(2 "Non-Western" 4 "Western" 6 "Danes") ///
position(5) row(4) ring(0) size(medium) rowgap(tiny)) ///
legend(off) ///
xlabel(, valuelabels labsize(medium) nogrid) ///
xtitle("Effect estimate") ///
xline(0,lpattern(dash) lcolor(black)) ///
xscale(r(20(10)20)) xlabel(-20(10)20) ///
coeflabels(overall = "Overall" underestimators = "Underestimators" ///
small = "Small overestimators" moderate = "Moderate overestimators" large = "Large overestimators" ) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
title("Size experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(num_exp,replace)

*Combine the three panel into one plot. Figure B.7:
graph combine welfare_exp crime_exp num_exp ///
,  row(2)  imargin(1 1 1 1) graphregion(margin(tiny) color(white)) plotregion(margin(zero))


**********************************************************
*Appendix B.6. Effect of Treatments on Policy Preferences*
**********************************************************
//Here we provide supplementary results for the results in the manuscript. 
//The effects of Table B.3 corresponds to the effects of Figure 3 
//in the manuscript. The results, for each treatment respectively, 
//can be replicated by running the following code:

*Upper panel of Table B.3 (welfare treatment)
*average effect across prior expectations
reg antiim_policy_01 welfare_treatment   if eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto overall
*effect among underestimators
reg antiim_policy_01 welfare_treatment  if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto underestimators
*effect among small overestimators
reg antiim_policy_01 welfare_treatment  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto small
*effect among moderate overestimators
reg antiim_policy_01 welfare_treatment  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto moderate
*effect among large overestimators
reg antiim_policy_01 welfare_treatment  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto large
*Upper panel of Table B.1:
esttab overall underestimators small moderate large, se label title("Welfare Treatment") mtitle("Full Sample" "Bias<0" "Small Overestimation" "Moderate Overestimation" "Large Overestimation") drop(_cons)

*outcome means and ses
sum antiim_policy_01  if  eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.
sum antiim_policy_01  if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.
sum antiim_policy_01  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.
sum antiim_policy_01  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.
sum antiim_policy_01  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.



*Middle panel of Table B.3 (crime treatment)
*average effect across prior expectations
reg antiim_policy_01 crime_treatment   if eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_welfarepost!=.,r
est sto overall_c
*effect among underestimators
reg antiim_policy_01 crime_treatment  if crime_cat==0 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.,r
est sto underestimators_c
*effect among small overestimators
reg antiim_policy_01 crime_treatment  if crime_cat==1 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.,r
est sto small_c
*effect among moderate overestimators
reg antiim_policy_01 crime_treatment  if crime_cat==2 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.,r
est sto moderate_c
*effect among large overestimators
reg antiim_policy_01 crime_treatment  if crime_cat==3 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.,r
est sto large_c
*Upper panel of Table B.1:
esttab overall_c underestimators_c small_c moderate_c large_c, se label title("Crime Treatment") mtitle("Full Sample" "Bias<0" "Small Overestimation" "Moderate Overestimation" "Large Overestimation") drop(_cons)

*outcome means and ses
sum antiim_policy_01  if  eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.
sum antiim_policy_01  if crime_cat==0 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.
sum antiim_policy_01  if crime_cat==1 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.
sum antiim_policy_01  if crime_cat==2 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.
sum antiim_policy_01  if crime_cat==3 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.


*Upper panel of Table B.3 (welfare treatment)
*average effect across prior expectations
reg antiim_policy_01 number_treatment   if eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto overall_n
*effect among underestimators
reg antiim_policy_01 number_treatment  if num_cat==0 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto underestimators_n
*effect among small overestimators
reg antiim_policy_01 number_treatment  if num_cat==1 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto small_n
*effect among moderate overestimators
reg antiim_policy_01 number_treatment  if num_cat==2 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto moderate_n
*effect among large overestimators
reg antiim_policy_01 number_treatment  if num_cat==3 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto large_n
*Upper panel of Table B.1:
esttab overall_n underestimators_n small_n moderate_n large_n, se label title("Seze Treatment") mtitle("Full Sample" "Bias<0" "Small Overestimation" "Moderate Overestimation" "Large Overestimation") drop(_cons)

*outcome means and ses
sum antiim_policy_01  if  eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.
sum antiim_policy_01  if num_cat==0 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.
sum antiim_policy_01  if num_cat==1 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.
sum antiim_policy_01  if num_cat==2 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.
sum antiim_policy_01  if num_cat==3 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.

 
 
************
*Figure B.8*
************ 
//In this section, we provide code to construct the robustness analyses that 
//supplements the main findings.
//Linear estimation of the interaction between the treatments and priors

*we reload data to avoid having to construct new variables
use "correcting_misperception_recoded.dta",clear //use data set with recoded variables

*Welfare experiment. Top left panel of Figure B.8:
*We regress the policy preference measure on the welfare information treatment,
*the welfare prior, and the linear interaction between the two
reg antiim_policy_01 c.c_welfareprior##welfare_treatment if crime_treatment == 0 ///
& number_treatment == 0 & eth1 == 1  & welfareposterior!=. ,r
margins, dydx(welfare_treatment) at(c_welfareprior=(-0.14(0.10)0.86)) 
marginsplot
*and extract the marginal effects of the treatment at different levels of the prior
est store Welfare_immigration_fear
mat a = r(table)'
svmat a, name(col)
mat at_ = r(at)
svmat at_, name(col_)
g c_welf1=.
replace c_welf1=-.14 in 12
replace c_welf1=-.04 in 13
replace c_welf1= .06 in 14
replace c_welf1= .16 in 15
replace c_welf1= .26 in 16
replace c_welf1= .36 in 17
replace c_welf1= .46 in 18
replace c_welf1= .56 in 19
replace c_welf1= .66 in 20
replace c_welf1= .76 in 21
replace c_welf1= .86 in 22
*Top left panel of Figure B.8
twoway histogram c_welfareprior if crime_treatment == 0 ///
& number_treatment == 0 & eth1 == 1, yaxis(2) lcolor(gray) bcolor(gs14) || ///
line b c_welf1,sort(c_welf1) lcolor(black) ///
|| line ul c_welf1,sort(c_welf1) lcolor(black) lpattern(dash) ytitle(Marginal Effect of Treatment) ///
|| line ll c_welf1,sort(c_welf1) lcolor(black) lpattern(dash) ///
legend(off) xlabel(,valuelabels  labsize(medsmall)) ///
ylabel(,valuelabels labsize(medsmall) nogrid) ///
ylabel(,axis(2) valuelabels angle(0) labsize(medsmall) nogrid) ///
yscale(r(-.1(0.1).2)) ylabel(-.1(0.1).2) ///
xtitle("Welfare prior", size(medsmall)) ///
ytitle("Marginal Effect of Treatment", size(medsmall)) ///
ytitle("Density", axis(2) size(medsmall)) ///
graphregion(margin(zero)) plotregion(lcolor(black)) ///
graphregion(color(white)) plotregion(fcolor(white)) ///
bgcolor(white) ///
title("Welfare experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(welf_exp,replace) 

*Crime experiment. Top right panel of Figure B.8.
*We do the same as above but for the crime treatment
reg antiim_policy_01 c.c_crimeprior##crime_treatment  ///
if number_treatment == 0 ///
& welfare_treatment == 0 & eth1 == 1 & crimeposterior!=.,r
margins, dydx(crime_treatment) at(c_crimeprior=(-0.21(0.10)0.79)) post
mat A=r(table)
mat B= A[1,12],A[5,12],A[6,12]\A[1,13],A[5,13],A[6,13]\A[1,14],A[5,14],A[6,14]\A[1,15],A[5,15],A[6,15] ///
\A[1,16],A[5,16],A[6,16]\A[1,17],A[5,17],A[6,17]\A[1,18],A[5,18],A[6,18] ///
\A[1,19],A[5,19],A[6,19]\A[1,20],A[5,20],A[6,20]\A[1,21],A[5,21],A[6,21] ///
\A[1,22],A[5,22],A[6,22]
matlist B
matrix colnames B = est_pc l95_pc u95_pc
svmat B,name(col__)
*
g c_welf2=.
replace c_welf2=-.21 in 1
replace c_welf2=-.11 in 2
replace c_welf2= -.01 in 3
replace c_welf2= .09 in 4
replace c_welf2= .19 in 5
replace c_welf2= .29 in 6
replace c_welf2= .39 in 7
replace c_welf2= .49 in 8
replace c_welf2= .59 in 9
replace c_welf2= .69 in 10
replace c_welf2= .79 in 11
*Top right panel of Figure B.8:
twoway histogram c_crimeprior if welfare_treatment==0 ///
& number_treatment == 0 & eth1 == 1  , yaxis(2) lcolor(gray) bcolor(gs14) ///
|| line col__1 c_welf2,sort(c_welf2) lcolor(black) ///
|| line col__2 c_welf2,sort(c_welf2) lcolor(black) lpattern(dash)  ///
|| line col__3 c_welf2,sort(c_welf2) lcolor(black) lpattern(dash) ///
legend(off) xlabel(,valuelabels  labsize(medsmall)) ///
ylabel(,valuelabels labsize(medsmall) nogrid) ///
ylabel(,axis(2) valuelabels angle(0) labsize(medsmall) nogrid) ///
xtitle("Crime prior", size(medsmall)) ///
ytitle("Marginal Effect of Treatment", size(medsmall)) ///
ytitle("Density", axis(2) size(medsmall)) ///
yscale(r(-.1(0.1).2)) ylabel(-.1(0.1).2) ///
graphregion(margin(zero)) plotregion(lcolor(black)) ///
graphregion(color(white)) plotregion(fcolor(white)) ///
bgcolor(white) ///
title("Crime experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(crime_exp,replace) 


*Size experiment. Top left panel of Figure B.8
reg antiim_policy_01 c.c_numberprior##number_treatment  ///
if crime_treatment == 0 ///
& welfare_treatment == 0 & eth1 == 1 & numberposterior!=.
margins, dydx(number_treatment) at(c_numberprior=(-0.08(0.10)0.92)) post
mat A=r(table)
mat B= A[1,12],A[5,12],A[6,12]\A[1,13],A[5,13],A[6,13]\A[1,14],A[5,14],A[6,14]\A[1,15],A[5,15],A[6,15] ///
\A[1,16],A[5,16],A[6,16]\A[1,17],A[5,17],A[6,17]\A[1,18],A[5,18],A[6,18] ///
\A[1,19],A[5,19],A[6,19]\A[1,20],A[5,20],A[6,20]\A[1,21],A[5,21],A[6,21] ///
\A[1,22],A[5,22],A[6,22]
matlist B
matrix colnames B = est_pn l95_pn u95_pn
svmat B,name(col___)
*
g c_welf3=.
replace c_welf3=-.08 in 1
replace c_welf3=.02 in 2
replace c_welf3= .12 in 3
replace c_welf3= .22 in 4
replace c_welf3= .32 in 5
replace c_welf3= .42 in 6
replace c_welf3= .52 in 7
replace c_welf3= .62 in 8
replace c_welf3= .72 in 9
replace c_welf3= .82 in 10
replace c_welf3= .92 in 11
*Bottom panel of Figure B.8:
twoway histogram c_numberprior if welfare_treatment==0 ///
& crime_treatment == 0 & eth1 == 1  , yaxis(2) lcolor(gray) bcolor(gs14) ///
|| line col___1 c_welf3,sort(c_welf3) lcolor(black) ///
|| line col___2 c_welf3,sort(c_welf3) lcolor(black) lpattern(dash)  ///
|| line col___3 c_welf3,sort(c_welf3) lcolor(black) lpattern(dash) ///
legend(off) xlabel(,valuelabels  labsize(medsmall)) ///
ylabel(,valuelabels labsize(medsmall) nogrid) ///
ylabel(,axis(2) valuelabels angle(0) labsize(medsmall) nogrid) ///
yscale(r(-.1(0.1).2)) ylabel(-.1(0.1).2) ///
xtitle("Size prior", size(medsmall)) ///
ytitle("Marginal Effect of Treatment", size(medsmall)) ///
ytitle("Density", axis(2) size(medsmall)) ///
graphregion(margin(zero)) plotregion(lcolor(black)) ///
graphregion(color(white)) plotregion(fcolor(white)) ///
bgcolor(white) ///
title("Size experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(num_exp,replace) 


*Combine the three panel into one plot. Figure B.8:
graph combine welf_exp crime_exp num_exp,row(2) imargin(1 1 1 1) graphregion(margin(tiny)) plotregion(margin(tiny)) ///
graphregion(color(white)) plotregion(fcolor(white)) 


************
*Figure B.9*
************ 
//Here we show the effects of the information treatments on each item of the overall
//measure of policy preferences

*Welfare experiment. Left panel of Figure B.9
//first we reverse code two policies so high values indicate immigration opposition
replace policyA_1 = (policyA_1*-1) + 5
 replace policyA_3 = (policyA_3*-1) + 5
//second we scale each item
foreach var of varlist policyA_2 policyA_1 policyA_3 policyB_1 policyB_2 policyB_3 {
replace `var'=(`var'-1)/4
} 
*

*recoding treatment and prior
rename welfare_treatment treatment1
rename c_welfareprior prior
*g new treatment indicator equal to the treatment (for plotting purposes)
g A1=treatment1
g A2=treatment1
g A3=treatment1
g B1=treatment1
g B2=treatment1
g B3=treatment1
*regress each item on the welfare information treatment and extract effect estimates
reg policyA_1 A1 if eth1 == 1 & number_treatment==0 & crime_treatment==0 & welfareposterior!=.,r
est sto eco_A_1
reg policyA_2 A2 if eth1 == 1 & number_treatment==0 & crime_treatment==0 & welfareposterior!=.,r
est sto eco_A_2
reg policyA_3 A3 if eth1 == 1 & number_treatment==0 & crime_treatment==0 & welfareposterior!=.,r
est sto eco_A_3
reg policyB_1 B1 if eth1 == 1 & number_treatment==0 & crime_treatment==0 & welfareposterior!=.,r
est sto eco_B_1
reg policyB_2 B2 if eth1 == 1 & number_treatment==0 & crime_treatment==0 & welfareposterior!=.,r
est sto eco_B_2
reg policyB_3 B3 if eth1 == 1 & number_treatment==0 & crime_treatment==0 & welfareposterior!=.,r
est sto eco_B_3
*re-rename the treatment and priors
rename treatment1 welfare_treatment 
rename prior c_welfareprior 


*Crime experiment. Middle panel of Figure B.9.
//Repeat the above process for the crime information treatment
rename crime_treatment treatment1
rename c_crimeprior prior
drop A1 A2 A3 B1 B2 B3
g A1=treatment1
g A2=treatment1
g A3=treatment1
g B1=treatment1
g B2=treatment1
g B3=treatment1
*
reg policyA_1 A1 if eth1 == 1 & number_treatment==0 & welfare_treatment==0 & crimeposterior!=.,r
est store crime_A_1
reg policyA_2 A2 if eth1 == 1 & number_treatment==0 & welfare_treatment==0 & crimeposterior!=.,r
est store crime_A_2
reg policyA_3 A3 if eth1 == 1 & number_treatment==0 & welfare_treatment==0 & crimeposterior!=.,r
est store crime_A_3
reg policyB_1 B1 if eth1 == 1 & number_treatment==0 & welfare_treatment==0 & crimeposterior!=.,r
est store crime_B_1
reg policyB_2 B2 if eth1 == 1 & number_treatment==0 & welfare_treatment==0 & crimeposterior!=.,r
est store crime_B_2
reg policyB_3 B3 if eth1 == 1 & number_treatment==0 & welfare_treatment==0 & crimeposterior!=.,r
est store crime_B_3
*
rename treatment1 crime_treatment 
rename prior c_crimeprior 


*Size experiment. Right panel of Figure B.9.
//Repeat the above process for the size information treatment
rename number_treatment treatment1
rename c_numberprior prior
drop A1 A2 A3 B1 B2 B3
g A1=treatment1
g A2=treatment1
g A3=treatment1
g B1=treatment1
g B2=treatment1
g B3=treatment1
*
reg policyA_1 A1 if eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & numberposterior!=.,r
est store number_A_1
reg policyA_2 A2 if eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & numberposterior!=.,r
est store number_A_2
reg policyA_3 A3 if eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & numberposterior!=.,r
est store number_A_3
reg policyB_1 B1 if eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & numberposterior!=.,r
est store number_B_1
reg policyB_2 B2 if eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & numberposterior!=.,r
est store number_B_2
reg policyB_3 B3 if eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & numberposterior!=.,r
est store number_B_3
rename treatment1 number_treatment 
rename prior c_numberprior 

*Plot all the effect estimates in one plot. Figure B.9:
coefplot (eco_A_3,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(A3)) ///
(eco_B_1,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(B1)) ///
(eco_B_2,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(B2)) ///
(eco_A_2,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(A2)) ///
(eco_B_3,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(B3))  ///
(eco_A_1,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(A1)) || ///
(crime_A_3,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(A3)) ///
(crime_B_1,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(B1)) ///
(crime_B_2,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(B2)) ///
(crime_A_2,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(A2)) ///
(crime_B_3,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(B3))   ///
(crime_A_1,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(A1)) || ///
(number_A_3,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(A3)) ///
(number_B_1,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(B1)) ///
(number_B_2,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(B2)) ///
(number_A_2,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(A2)) ///
(number_B_3,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(B3))  ///
(number_A_1,  msymbol(circle) mcolor(black) ciopts(lcolor(black)) keep(A1)) ///
, nooffset  xtitle("Effect Estimates") byopts(row(1) legend(off)) ///
coeflabels(A3="Refugees 1" B1="Refugees 2" ///
B2="Refugees 3" A2="Immigrants 1" B3="Immigrants 2" A1="Refugees and Immigrants") ///
xline(0,lpattern(dash) lcolor(black)) ///
ylabel(, valuelabels  labsize(medsmall) nogrid) graphregion(margin(zero)) plotregion(lcolor(black))  grid(no) ///
xscale(r(-0.1(0.05)0.1)) xlabel(-0.1(0.05)0.1) ///
xlabel(,valuelabel nogrid labsize(medsmall)) ///
graphregion(color(white)) ///
bgcolor(white) plotregion(fcolor(white)) ///
name(items,replace)



*******************************************************
*Appendix B.7. Effect of Treatments on Interpretations*
*******************************************************
//Here we provide supplementary results for the results in the manuscript. 
//The effects of Table B.4 corresponds to the effects of Figure 4 
//in the manuscript. The results, for each treatment respectively, 
//can be replicated by running the following code:

*Upper panel of Table B.4 (welfare treatment)
*average effect across prior expectations
reg welfareinterpretation_01 welfare_treatment   if eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto overall
*effect among underestimators
reg welfareinterpretation_01 welfare_treatment  if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto underestimators
*effect among small overestimators
reg welfareinterpretation_01 welfare_treatment  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto small
*effect among moderate overestimators
reg welfareinterpretation_01 welfare_treatment  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto moderate
*effect among large overestimators
reg welfareinterpretation_01 welfare_treatment  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.,r
est sto large
*Upper panel of Table B.1:
esttab overall underestimators small moderate large, se label title("Welfare Treatment") mtitle("Full Sample" "Bias<0" "Small Overestimation" "Moderate Overestimation" "Large Overestimation") drop(_cons)

*outcome means and ses
sum welfareinterpretation_01  if  eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.
sum welfareinterpretation_01  if welf_cat==0 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.
sum welfareinterpretation_01  if welf_cat==1 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.
sum welfareinterpretation_01  if welf_cat==2 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.
sum welfareinterpretation_01  if welf_cat==3 & eth1 == 1 & number_treatment==0 & crime_treatment==0 & c_welfarepost!=.



*Middle panel of Table B.3 (crime treatment)
*average effect across prior expectations
reg crimeinterpretation_01 crime_treatment   if eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_welfarepost!=.,r
est sto overall_c
*effect among underestimators
reg crimeinterpretation_01 crime_treatment  if crime_cat==0 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.,r
est sto underestimators_c
*effect among small overestimators
reg crimeinterpretation_01 crime_treatment  if crime_cat==1 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.,r
est sto small_c
*effect among moderate overestimators
reg crimeinterpretation_01 crime_treatment  if crime_cat==2 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.,r
est sto moderate_c
*effect among large overestimators
reg crimeinterpretation_01 crime_treatment  if crime_cat==3 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.,r
est sto large_c
*Upper panel of Table B.1:
esttab overall_c underestimators_c small_c moderate_c large_c, se label title("Crime Treatment") mtitle("Full Sample" "Bias<0" "Small Overestimation" "Moderate Overestimation" "Large Overestimation") drop(_cons)

*outcome means and ses
sum crimeinterpretation_01  if  eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.
sum crimeinterpretation_01  if crime_cat==0 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.
sum crimeinterpretation_01  if crime_cat==1 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.
sum crimeinterpretation_01  if crime_cat==2 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.
sum crimeinterpretation_01  if crime_cat==3 & eth1 == 1 & number_treatment==0 & welfare_treatment==0 & c_crimepost!=.


*Upper panel of Table B.3 (welfare treatment)
*average effect across prior expectations
reg numberinterpretation_01 number_treatment   if eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto overall_n
*effect among underestimators
reg numberinterpretation_01 number_treatment  if num_cat==0 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto underestimators_n
*effect among small overestimators
reg numberinterpretation_01 number_treatment  if num_cat==1 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto small_n
*effect among moderate overestimators
reg numberinterpretation_01 number_treatment  if num_cat==2 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto moderate_n
*effect among large overestimators
reg numberinterpretation_01 number_treatment  if num_cat==3 & eth1 == 1 & welfare_treatment==0 & crime_treatment==0 & c_numpost!=.,r
est sto large_n
*Upper panel of Table B.1:
esttab overall_n underestimators_n small_n moderate_n large_n, se label title("Seze Treatment") mtitle("Full Sample" "Bias<0" "Small Overestimation" "Moderate Overestimation" "Large Overestimation") drop(_cons)

*outcome means and ses
sum numberinterpretation_01  if  eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.
sum numberinterpretation_01  if num_cat==0 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.
sum numberinterpretation_01  if num_cat==1 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.
sum numberinterpretation_01  if num_cat==2 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.
sum numberinterpretation_01  if num_cat==3 & eth1 == 1 & crime_treatment==0 & welfare_treatment==0 & c_numpost!=.

	
*************
*Figure B.10*
************* 
//In this section, we provide code to construct the robustness analyses that 
//supplements the main findings.
//Linear estimation of the interaction between the treatments and priors

*we reload data to avoid having to construct new variables
use "correcting_misperception_recoded.dta",clear //use data set with recoded variables

*Welfare experiment. Top left panel of Figure B.10:
*We regress the interpretations measure on the welfare information treatment,
*the welfare prior, and the linear interaction between the two
reg welfareinterpretation_01 c.c_welfareprior##welfare_treatment if crime_treatment == 0 ///
& number_treatment == 0 & eth1 == 1  & welfareposterior!=. ,r
margins, dydx(welfare_treatment) at(c_welfareprior=(-0.14(0.10)0.86)) 
marginsplot
*and extract the marginal effects of the treatment at different levels of the prior
est store Welfare_immigration_fear_2
mat a = r(table)'
svmat a, name(col)
mat at_ = r(at)
svmat at_, name(col_)
g c_welf1=.
replace c_welf1=-.14 in 12
replace c_welf1=-.04 in 13
replace c_welf1= .06 in 14
replace c_welf1= .16 in 15
replace c_welf1= .26 in 16
replace c_welf1= .36 in 17
replace c_welf1= .46 in 18
replace c_welf1= .56 in 19
replace c_welf1= .66 in 20
replace c_welf1= .76 in 21
replace c_welf1= .86 in 22
*finally we plot the marginal effect together with a histogram of the distribution of the prior
twoway histogram c_welfareprior if crime_treatment == 0 ///
& number_treatment == 0 & eth1 == 1, yaxis(2) lcolor(gray) bcolor(gs14) || ///
line b c_welf1,sort(c_welf1) lcolor(black) ///
|| line ul c_welf1,sort(c_welf1) lcolor(black) lpattern(dash) ytitle(Marginal Effect of Treatment) ///
|| line ll c_welf1,sort(c_welf1) lcolor(black) lpattern(dash) ///
legend(off) xlabel(,valuelabels  labsize(medsmall)) ///
ylabel(,valuelabels labsize(medsmall) nogrid) ///
ylabel(,axis(2) valuelabels angle(0) labsize(medsmall) nogrid) ///
yscale(r(-.1(0.1).4)) ylabel(-.1(0.1).4) ///
xtitle("Welfare prior", size(medsmall)) ///
ytitle("Marginal Effect of Treatment", size(medsmall)) ///
ytitle("Density", axis(2) size(medsmall)) ///
graphregion(margin(zero)) plotregion(lcolor(black)) ///
graphregion(color(white)) plotregion(fcolor(white)) ///
bgcolor(white) ///
title("Welfare experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(welf_exp,replace) 

*Crime experiment. Top right panel of Figure B.10.
*We do the same as above but for the crime treatment
reg crimeinterpretation_01 c.c_crimeprior##crime_treatment  ///
if number_treatment == 0 ///
& welfare_treatment == 0 & eth1 == 1 & crimeposterior!=.,r
margins, dydx(crime_treatment) at(c_crimeprior=(-0.21(0.10)0.79)) post
mat A=r(table)
mat B= A[1,12],A[5,12],A[6,12]\A[1,13],A[5,13],A[6,13]\A[1,14],A[5,14],A[6,14]\A[1,15],A[5,15],A[6,15] ///
\A[1,16],A[5,16],A[6,16]\A[1,17],A[5,17],A[6,17]\A[1,18],A[5,18],A[6,18] ///
\A[1,19],A[5,19],A[6,19]\A[1,20],A[5,20],A[6,20]\A[1,21],A[5,21],A[6,21] ///
\A[1,22],A[5,22],A[6,22]
matlist B
matrix colnames B = est_pc l95_pc u95_pc
svmat B,name(col__)
*
g c_welf2=.
replace c_welf2=-.21 in 1
replace c_welf2=-.11 in 2
replace c_welf2= -.01 in 3
replace c_welf2= .09 in 4
replace c_welf2= .19 in 5
replace c_welf2= .29 in 6
replace c_welf2= .39 in 7
replace c_welf2= .49 in 8
replace c_welf2= .59 in 9
replace c_welf2= .69 in 10
replace c_welf2= .79 in 11
*
twoway histogram c_crimeprior if welfare_treatment==0 ///
& number_treatment == 0 & eth1 == 1  , yaxis(2) lcolor(gray) bcolor(gs14) ///
|| line col__1 c_welf2,sort(c_welf2) lcolor(black) ///
|| line col__2 c_welf2,sort(c_welf2) lcolor(black) lpattern(dash)  ///
|| line col__3 c_welf2,sort(c_welf2) lcolor(black) lpattern(dash) ///
legend(off) xlabel(,valuelabels  labsize(medsmall)) ///
ylabel(,valuelabels labsize(medsmall) nogrid) ///
ylabel(,axis(2) valuelabels angle(0) labsize(medsmall) nogrid) ///
yscale(r(-.1(0.1).4)) ylabel(-.1(0.1).4) ///
xtitle("Crime prior", size(medsmall)) ///
ytitle("Marginal Effect of Treatment", size(medsmall)) ///
ytitle("Density", axis(2) size(medsmall)) ///
graphregion(margin(zero)) plotregion(lcolor(black)) ///
graphregion(color(white)) plotregion(fcolor(white)) ///
bgcolor(white) ///
title("Crime experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(crime_exp,replace) 


*Size experiment. Top left panel of Figure B.10
reg numberinterpretation_01 c.c_numberprior##number_treatment  ///
if crime_treatment == 0 ///
& welfare_treatment == 0 & eth1 == 1 & numberposterior!=.
margins, dydx(number_treatment) at(c_numberprior=(-0.08(0.10)0.92)) post
mat A=r(table)
mat B= A[1,12],A[5,12],A[6,12]\A[1,13],A[5,13],A[6,13]\A[1,14],A[5,14],A[6,14]\A[1,15],A[5,15],A[6,15] ///
\A[1,16],A[5,16],A[6,16]\A[1,17],A[5,17],A[6,17]\A[1,18],A[5,18],A[6,18] ///
\A[1,19],A[5,19],A[6,19]\A[1,20],A[5,20],A[6,20]\A[1,21],A[5,21],A[6,21] ///
\A[1,22],A[5,22],A[6,22]
matlist B
matrix colnames B = est_pn l95_pn u95_pn
svmat B,name(col___)
*
g c_welf3=.
replace c_welf3=-.08 in 1
replace c_welf3=.02 in 2
replace c_welf3= .12 in 3
replace c_welf3= .22 in 4
replace c_welf3= .32 in 5
replace c_welf3= .42 in 6
replace c_welf3= .52 in 7
replace c_welf3= .62 in 8
replace c_welf3= .72 in 9
replace c_welf3= .82 in 10
replace c_welf3= .92 in 11
*
twoway histogram c_numberprior if welfare_treatment==0 ///
& crime_treatment == 0 & eth1 == 1  , yaxis(2) lcolor(gray) bcolor(gs14) ///
|| line col___1 c_welf3,sort(c_welf3) lcolor(black) ///
|| line col___2 c_welf3,sort(c_welf3) lcolor(black) lpattern(dash)  ///
|| line col___3 c_welf3,sort(c_welf3) lcolor(black) lpattern(dash) ///
legend(off) xlabel(,valuelabels  labsize(medsmall)) ///
ylabel(,valuelabels labsize(medsmall) nogrid) ///
ylabel(,axis(2) valuelabels angle(0) labsize(medsmall) nogrid) ///
yscale(r(-.1(0.1).4)) ylabel(-.1(0.1).4) ///
xtitle("Size prior", size(medsmall)) ///
ytitle("Marginal Effect of Treatment", size(medsmall)) ///
ytitle("Density", axis(2) size(medsmall)) ///
graphregion(margin(zero)) plotregion(lcolor(black)) ///
graphregion(color(white)) plotregion(fcolor(white)) ///
bgcolor(white) ///
title("Size experiment", size(medium) color(black) box bexpand bcolor(gs14) lcolor(black)) ///
name(num_exp,replace) 


*We combine these three panels into one plot. Figure B.10:
graph combine welf_exp crime_exp num_exp,row(2) imargin(1 1 1 1) graphregion(margin(tiny)) plotregion(margin(tiny)) ///
graphregion(color(white)) plotregion(fcolor(white)) 

log close correcting_misperception_recoded
